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();
....
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.
Here is what I've been used for adding new row with Button
function add_new_row(){
item = {"id": (Math.round(Math.random()*-10000))
//you can add another fields to fill default data on Adding new row
};
data_view.insertItem(0, item);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With