It's actually quite simple. You need to reload the data array after your Insert/Edit/Delete operations. How do you do it.
1. Create your koolgrid as usual.
2. Add an event handler.
3. On insert, make use of a global, or object property that you can access in your grid's event handler functions
- OnTableViewPreRender
- OnBeforeConfirmInsert
On your insert function, OnBeforeConfirmInsert, if it completes the process successfully, then set this variable to true.
Example :
...
// This variable will be checked in my tableview prerender function
$_REQUEST['SavingNewWebLeadFieldData'] = true ;
...
Now, in your OnTableViewPreRender do the following :
/**
* Occurring before the grid renders. You can make any neccessary changes here before the grid is in rendering process.
* 1. Check and see if the array datasource needs to refresh.
* Variable : $_REQUEST['SavingNewWebLeadFieldData'] is boolean
* It tells the grid prerender process refresh the data array
* @param GridTableView $grid
* @param array $args
*/
function OnTableViewPreRender($grid,$args)
{
if( isset( $_REQUEST['SavingNewWebLeadFieldData'] ) && is_bool( $_REQUEST['SavingNewWebLeadFieldData'] ) )
{
if( $_REQUEST['SavingNewWebLeadFieldData'] === true )
{
$this->grid->BuildDataSourceArray(); // original grid object set on the constructor.
$grid->DataSource = new AdvancedArrayDataSource( $this->grid->GridMappedFields );
$grid->refresh();
}
}
}
Hope this helps somebody.