3
votes

I have a SlickGrid in which the user can choose various datasets. Thus the schema can change. So when the user selects a new dataset, I need to either delete the SlickGrid and start over, or clear the existing one.

What is the proper approach? Should I just delete the DOM node? I have looked through the API and cannot find any grid level calls that appears to accomplish what I am looking to do.

thanks

4
You can update the DataView with the new values and call invalidateRows on the grid. - dchhetri
I am binding using an array of columns and an array of rows. Not a dataview. I'll look into that though. thanks. - user1883165
either way, if data has changed, you have to tell slickgrid that it has changed. One way is via invalidateRows - dchhetri
change the data and call grid.invalidateRows() and then grid.render() - Premshankar Tiwari

4 Answers

9
votes

Use Data view and "OnChange()" call following lines,

grid.invalidateAllRows();
dataView.setItems(newData, "Id");
grid.render();

If your not using dataview try this,

        var data = []; \\or new array
        grid.setData(data);
        grid.render();
2
votes

Below code did the job for me to reset the slickgrid from javascript

dataView.beginUpdate();
dataView.getItems().length = 0;
dataView.endUpdate();
0
votes

Call:

grid.setData(<new data>)

0
votes
Any of the following can be used to add data


//add data using slickgrid object
data.splice(data.length, 1, item);
grid.setData(data);
grid.invalidateRow(data.length);
grid.render();


//add single item using data view
dataView.addItem(item);
grid.updateRowCount();
grid.invalidateRow(data.length);
grid.render();


//set all new data set in grid, using a new set of data including added on (Mutliple rows)
data.splice(data.length, 1, item);
dataView.setItems(data, 'ID');   
grid.invalidateAllRows();
grid.render();