How to add a row using javascript in SlickGrid

Khaja Minhajuddin picture Khaja Minhajuddin · Jun 21, 2010 · Viewed 10.4k times · Source

I am trying to add a row to a slick grid on my page using javascript. The way I am able to do it now is by using the following code. I was just wondering if there was a better way to do the same.

....

//data is the array which was used to populate the SlickGrid
data.push({name:'Finish scanning the slickgrid js', complete:false}); 
grid.setData(data);
grid.render();

....

Answer

Tin picture Tin · Jun 21, 2010

This is the preferred way.

data.push({...});
grid.updateRowCount();
grid.render();

Calling .setData() forced the grid to re-render everything. By calling updateRowCount() you are notifying the grid the number of the rows have changed and that it needs to render what has been added or removed only.