APPLICABLE TO: Grid
Starting from version 1.0, connectors can be used to define the header of Grid.
It can be done in 2 ways:
In case of automatic defining, Grid will use names of a 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 an automatic server-side sorting and filtering for the specified columns, you should specify true inside of GridConfiguration:
$grid->set_config(new GridConfiguration(true));
$grid->render_table("grid50000","item_id","item_nm,item_cd");
In the manual mode the headers and their parameters are defined by php command. Names of commands mimic the names of the js commands with a 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");
All commands below get as the input parameter an array of values or a 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 a column
$config->setColHidden($hidStr);//'true' if a column must be hidden, 'false' otherwise.
To attach a header to the grid you should use the attachHeader() method:
$config->attachHeader($values, $styles = null);
Parameters:
To attach a footer to the grid you should use the attachFooter() method:
$config->attachFooter($values, $styles = null);
Parameters:
The header delimeter sets a symbol or several symbols which will be used as a delimiter in string arguments.
$config->setHeaderDelimiter($headerDelimiter);