Add, Update or Highlight a Datagrid Item
index
Description
When working with the grid, you might want to Add / Update or Hightlight an item row from the Datagrid.
Note: This is strictly a client side event, you still have to implement any backend change yourself.
Demo
CRUD Methods
Add an Item (row)
Please note that you need to provide the id by yourself and remember that it has to be unique, else the Slickgrid DataView will throw you an error in the console.
Component
Add Item Position (top/bottom)
When adding an item, you can add it on top (default) of the grid or at the bottom of the grid. In order to change that, you can use the position property.
Change default flags
When adding an item, you have access to change any of the default flags through the second argument of addItem method.
Delete an Item (row)
To delete a row, you can use deleteItem(s) and the pass the entire object(s) or use deleteItemById(s) in which you need to provide the object id` to delete and the method will find it in the grid and remove it from the grid. Also please note that it's only deleting from the grid (by removing it from the DataView), meaning that it won't remove it from your database.
Component
Change default flags
When adding an item, you have access to change any of the default flags through the second argument of addItem method.
Update an Item (row)
To update an item, you can use updateItem(s) and the pass the entire object(s) in this case it does not require you to know the row number, it will try to find the row by itself (it uses the "id" for that) and update the item. The other way would be to use updateItemById in which you need to provide the object id to update the item.
Component
Change default flags
When adding an item, you have access to change any of the default flags through the second argument of addItem method.
Upsert an Item (row)
Upsert will do an Insert when not found or update if it found the item already exist in the grid.
Component
CRUD Default Option Flags
All the CRUD methods have default option flags that can be changed which will do certain actions. The default option flags are the following for each of the CRUD method (upsert will use the flags of the insert or the update depending on which method it calls).
Highlight a row item
Highlighting a row is customizable with SASS, you can change the highlighted color and/or animation by changing the SASS variables $row-highlight-background-color and/or $row-highlight-fade-animation
Take a look at all the available SASS variables.
Component
Last updated