Dynamic loading
Dynamical Loading mode allows to load data not all at once, but partially, by client-side request. It decreases initial loading time and loading of server.
To work correctly, on client-side should be enabled related mode:
- grid - smart rendering and paging modes
- treegrid - dynamic branch loading mode
- tree - dynamic branch loading mode
- combo - partial autocomplete ( you don't need it for normal autocomplete)
- dataview - dynamiс scrolling or dynamic paging
To activate the mode you should use the method dynamic_loading():
$grid->dynamic_loading([$rowsNum]);
Parameters:
- none for a tree,treegrid.
- number of rows which should be initially loaded (the value should be more than a number of rows visible in the grid, or at least any positive number) for a grid.
- maximum number of options which server will send to a combo in the 'autocomplete mode' for a single data request.
tree/treegrid specific
Normally, connector makes all operations automatically, and doesn't need customization.
But, in case of dynamic loading in tree/treeGrid, database can contain field indicated leaf or branch the current item is.
In beforeRender event handler you are allowed to mark an item as a leaf or branch (it decreases a number of SQL queries and increases perfomance).
function custom_define($item){ if ($item->get_value("is_a_branch")) $item->set_kids(true); else $item->set_kids(false); } $tree->event->attach("beforeRender","custom_define");
The same approach can be used for non-dynamical mode of tree/treeGrid as well. It's not obligatory but lets you increase data generation performance.