By means of using the render_sql() or render_table() methods you can assign aliases to required tables or columns. For this purpose, in sql statement you should use the word 'as' (as in any usual sql statement), in other parameters - parentheses.
$grid->render_table("tableA","id","name,price(product_price)");
//or
$grid->render_sql("Select *,tableA.id as aid from tableA,tableB where tableA.id=tableB.id",
"tableA.id(aid)","name,price(product_price)");
To attach event you should use event->attach(). For more details on this topic, see the 'Handling Events' guide.
$conn->event->attach(event_name,handlerFunc);
The value of any item can be checked by the get_value() method.
$grid->get_value($name);
To add a custom error message you can use the event onDBError and write the desired message in the appropriate handler.
function doOnDBError($action, $exception){
$action->set_response_text("Some details about error")
}
$conn->event->attach("onDBError",doOnDBError);
You can use the beforeRender event to define how the content of a cell must be formatted.
function custom_data($row){
$data = $row_get_value("some_column");
$row->set_value("some_column", "$data <input type='text' />")
}
$grid->event->attach("beforeRender","custom_data");
In the sample above the grid will have a custom content - html input 'text'.
You have 3 ways to filter data on the server backend:
grid.load("some.php?connector=true&dhx_filter[1]=mask");
mygrid.setHeader("Column A, Column B");
mygrid.attachHeader("#connector_text_filter,#connector_select_filter")
function custom_filter($data){
...
}
$conn->event->attach("beforeRender","custom_filter");
See the guide 'Filtering' for more information.
You can enable logging with the help of the enable_log() method. For more details see the 'Error handling and logging' guide.
$conn->enable_log("path to log file");//to show short info on the client side
_or
$conn->enable_log("path to log file", true);// to show full info on the client side
You can secure your app from XSS, CSRF and XSRF attacks and deny access to certain groups of users. For more details, see the guide 'Security'.
By using the set_value() method, you can set value to any item of a component.
$dataItem->set_value($name,$value)
You have 2 ways to sort data on the server backend:
grid.load("some.php?connector=true&dhx_sort[2]=asc");
grid.setColSorting("connector,str,na);
For more information, see the 'Sorting' guide.
dataProcessor lets you validate data on the client side. Use the setVerificator(index,method) method to define the appropriate columns and validators. See details in the related chapter of dataProcessor' documentation.
dp.setVerificator(column_index,verification_func)
To perform server-side validation you should use one of the dhtmlxConnector events stated below and specify the needed validation rules in the appropriate events' handlers functions:
function validate($data){
...
}
$conn->event->attach("beforeProcessing","validate");
For more details on the server-side validation, see the 'Validation' guide.
Back to top