DEFINING GRID STRUCTURE ON SERVER-SIDE
APPLICABLE TO: Grid
Starting from version 1.0, connectors can be used to define header of grid.
It can be done in 2 ways:
automatic defining
In case automatic defining, grid will use names of table's fields as labels for the columns.
require("../../codebase/grid_connector.php"); $grid = new GridConnector($res); $grid->set_config(new GridConfiguration()); $grid->render_table("grid50000","item_id","item_nm,item_cd");
If you want to apply automatic server-side sorting and filtration for specified columns, you should specify true inside GridConfiguration:
$grid->set_config(new GridConfiguration(true)); $grid->render_table("grid50000","item_id","item_nm,item_cd");
manual defining
In manual mode, headers and their parameters are defined by php command. Names of commands mimic names of js commands with similar functionality.
$config = new GridConfiguration(); $config->setHeader(array("column 1","column 2")); $config->setColTypes(array("ro","ed")); $grid->set_config($config); $grid->render_table("grid50000","item_id","item_nm,item_cd");
available commands
All commands below, get as input parameter an array of values or comma-separated string, delimited by 'header delimiter' (default value - ',').
// column labels $config->setHeader($names); // column types $config->setColTypes($typeStr); // column IDs $config->setColIds($idsStr); // column width, int values, will be processed as size in pixels $config->setInitWidths($widths); // column width, int value, will be threated as size in percents $config->setInitWidthsP($widths); // column align $config->setColAlign($alStr); // column sorting type $config->setColSorting($sortStr); // column color $config->setColColor($colorStr); // visibility of column $config->setColHidden($hidStr);//'true' if column must be hidden, 'false' otherwise.
header and footer
- To attach header to the grid you should use attachHeader() method:
$config->attachHeader($values, $styles = null);
Parameters:
- array or string of header names. In case of string, names are delimited by 'header delimiter' (default value -',')
- array or string of header styles. In case of string, styles are delimited by 'header delimiter' (default value - ',')
- To attach footer to the grid you should use attachFooter() method:
$config->attachFooter($values, $styles = null);
Parameters:
- array or string of footer names. In case of string, names are delimited by 'header delimiter' (default value - ',')
- array or string of footer styles. In case of string, styles are delimited by 'header delimiter' (default value - ',')
header delimiter
Header delimeter sets symbol or several symbols which will be used as delimiter in string arguments.
$config->setHeaderDelimiter($headerDelimiter);