3

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

user1883165
  • 31
  • 1
  • 1
  • 2

4 Answers4

9

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();
Jatin patil
  • 4,252
  • 1
  • 18
  • 27
2

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

dataView.beginUpdate();
dataView.getItems().length = 0;
dataView.endUpdate();
Arivarasan L
  • 9,538
  • 2
  • 37
  • 47
0

Call:

grid.setData(<new data>)

Tin
  • 9,082
  • 2
  • 34
  • 32
  • What I tried last night was : grid.setData({}); grid.SetColumns({}); grid.setColumns(newColumns); grid.setData(newRows); That did not appear to work. I'll give it another shot tonight. – user1883165 Jul 15 '13 at 19:19
0
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();
Nishant Baranwal
  • 1,048
  • 1
  • 10
  • 18