Open dininski opened 11 years ago
@dininski
Try something along the lines of the following. It worked for me. I am having issues with the last column "disappearing" but that may be an entirely different issue. Hope it helps.
var _gridster = [GRIDSTER init code here]
for (var i = 0; i < widgetCount; i++) {
var el = $('div.widget[data-id="' + widgets[i].data_id + '"');
var dataRow = Math.floor(i / colCount) + 1;
var dataCol = (i % colCount) + 1;
el.attr("data-row", dataRow);
el.attr("data-col", dataCol);
//el.attr("data-sizex", "1");
//el.attr("data-sizey", "1");
}
_gridster.init();
@dininski
Actually, don't run the init() call. It seems that if you just update the positioning - say on window resize or something - gridster takes care of the rest. Good luck!
And if you call the init twice, it will also cause troubles.
@lucknerjb thanks!
Hi,
I have the following issue - I have a page and some gridster widgets on it. Their positions are saved in a database so that the next time a user opens the page his widgets are in the same place as he left them (I am saving a widget's position, size and element id in a database). What I am attempting to do is display all widgets and then re-position them. I managed to set their position using the dataset property of the widget, but the gridmap is not updated which leads to problems with dragging the elements.
I managed to get a somewhat working version by removing all the widgets and then adding them one by one with an updated position, however the performance is abysmal and there should be a better way. I even tried extending the code so that the gridmap can be rebuilt from scratch, but to no avail. Please advise if there is a better way on achieving this functionality.