To enable dynamic loading you should:
grid.enableSmartRendering(mode,buffer);
See the guide 'Dynamic loading' for more information.
To set some specific formatting or change data before sending to client-side, you should use the beforeRender event handler. For more details of this topic, see 'Formatting/Changing Data before Loading'
function color_rows($row){ if ($row->get_index()%2) $row->set_row_color("red"); } $grid->event->attach("beforeRender","color_rows");
To load data from database table you should use one of two methods:
$grid->render_table("tableA","item_id","column1,column2", "extra_column3");
$grid->render_sql("Select * from tableA, tableB where tableA.id=tableB.id", "tableA.id","column1,column2");
To load data from Excel file you should download phpExcel library from http://support.dhtmlx.com/x-files/connector/phpExcel.zip and include additional files:
Then, call render_table()) method where as parameters you should specify cell range and Excel columns. Set the second parameter to 'id' for auto id generation.
//files from phpExcel package require_once('lib/PHPExcel.php'); require_once('lib/PHPExcel/IOFactory.php'); //connectors require("../../codebase/db_excel.php"); require("../../codebase/grid_connector.php"); $grid = new GridConnector("../some.xls", "ExcelDBDataWrapper"); $grid->render_table("A18:F83", "id", "A,B,C,D,E,F");
For more details, see the guide chapter 'loading from Excel file' in 'Base concepts' guide.
To load data from File System you should include one additional file db_filesystem.php and call render_table() method where as parameters you should specify folder (that requires data listing), field's id (leave it empty or use safe_name as ID of file) and lists of fields.
require("./codebase/connector/db_filesystem.php"); require("./codebase/connector/grid_connector.php"); $grid = new GridConnector("", "FileSystem"); $grid->render_table("../","safe_name","filename,full_filename,size,name,extention,date,is_folder");
For more details, see the guide chapter 'loading from File System' in 'Base concepts' guide.
To send additional information to client-side that won't be outputed but you'll have access to it, use the fourth(optional) parameter of render_table() method. There you should specify columns that contain desired additional information.
$grid->render_table("some_table","id","name,price","color,count");
For more inoformation, see the chapter 'Using extra fields' in 'Formatting/Changing Data before Loading' guide.