angular2gridster icon indicating copy to clipboard operation
angular2gridster copied to clipboard

Adding components dynamically

Open julianodev opened this issue 6 years ago • 11 comments

Hi, devs !

Is it possible to add dynamic components inside a gridster container?

Ex: I have 2 components.

Component A, Component B,

I tried using ComponentFactoryResolver, but it does not seem to be interesting because I have to declare <ng-template #container> </ ng-template>.

Would you have another solution?

My idea is to have a List of components where the user can choose one and I add it as gridster item.

Thank you.

julianodev avatar Apr 02 '18 20:04 julianodev

The easiest way to do it is to use a library e.g. https://github.com/gund/ng-dynamic-component

swiety85 avatar Apr 03 '18 17:04 swiety85

Could I add them inside N gridsterItem?

I'll check out this library.

julianodev avatar Apr 03 '18 17:04 julianodev

How can I leave the grid? see an example in this gif repair my mouse cursor gridster2-dynamic

julianodev avatar Apr 04 '18 19:04 julianodev

gridster2-dynamic2

Hello,

Notice my gridster container.

When I finish adding the items and close my side menu it apparently can not calculate the size of my container.

it apparently pops up the width of the container and does not consider adding the items in that space

Could this be a bug in my css?

I am using the same settings as your example in the Responsiveness part

My method for adding an item to gridlist

config-add-item

julianodev avatar Apr 05 '18 18:04 julianodev

Hard to say... Do you call gridsterComponent.reload() after the animation of closing and opening side menu is finished?

swiety85 avatar Apr 05 '18 19:04 swiety85

Hello,

I was able to solve these problems, it was css error was calculating wrong.

The only thing I could not solve was that if I did not have a widget and wanted to drag an item it can not I would have to set a height for the .dashboard but it overrides my other css

This content when I do not have any widget added yet.

And when I drag a new item it does not seem to work.

ex :

add-widget

julianodev avatar Apr 05 '18 20:04 julianodev

Again it's hard to suggest any solution if I don't see your html and css. Maybe try to set min-height on .gridster-container..

swiety85 avatar Apr 05 '18 20:04 swiety85

@julianodev I like your dashboard images, I am trying to do the same thing. Can you please provide like to your demo.

dipaktelangre avatar May 16 '18 12:05 dipaktelangre

Could I add them inside N gridsterItem?

I'll check out this library.

Any way to get a look at your code? Example?

tdmitchal avatar Dec 31 '18 18:12 tdmitchal

@julianodev Hi. Could you please update us on what happened? And if you solved it please show us how. :)

C-odes avatar Jan 02 '19 11:01 C-odes

@julianodev can you share your code to use dynamic component for gridster

viethien avatar Apr 02 '19 07:04 viethien