0

I would like to use Gridstack for my project and I am playing with it, right now I am adding widgets with JSON data. I am not able to add an id to the widget.

Here is a link to JsFiddle. This 'id' is very important because without it I wont be able to save/retrieve data from DB.

According to this post on guthub, I am providing the id to ** grid.add_widget** method. But I don't know how I can access it.

Kamran
  • 4,010
  • 14
  • 60
  • 112

1 Answers1

2

According to the post on github that you provided (https://github.com/troolee/gridstack.js/issues/188) this functionality was implement in version 0.2.5 and you are using version 0.2.3 in your example.

So in order to make it work you should first update gridstack library in your project and then use .addWidget (add_widget is now deprecated) function with updated set of arguments:

addWidget(el[, x, y, width, height, autoPosition, minWidth, maxWidth, minHeight, maxHeight, id])

Based on your example it should look something like this:

grid.addWidget($element, node.x, node.y, node.width, node.height, true, null, null, null, null, node.id);

You can check the updated example here: https://jsfiddle.net/s9tc3u0m/2/

TV.
  • 232
  • 1
  • 3
  • 14