Skip to main content

Step 5. Bind Toolbar to Grid

At this step we will discuss how to fill and clear the Grid with the help of Toolbar buttons. For this purpose we will use the Click event of the Toolbar:

toolbar.events.on("Click", function(id,e){ 
//id - toolbar button id, e - default mouse event of browser
switch(id) {
case 'load': {
grid.data.parse(grid_dataset);
break;
}
case 'clear': {
grid.data.removeAll();
break;
}
}
});
If you click on the "Load" icon the data will be parsed into the Grid with the help of the parse() method. We've already prepared the data set in the previous step. If you click on the "Clear" icon, all items will be deleted from the grid through the removeAll() method.

For more information about working with the Toolbar events, see the article. The methods used to work with data are described in data_collection/api/refs/datacollection.md.