Check documentation for the latest version of dhtmlxSuite General HowTos DHTMLX Docs

General HowTos

How can I assign aliases to DB columns?

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_sql("Select *, as aid from tableA,tableB where", 

How can I attach event?

To attach event you should use event->attach(). For more details on this topic, see the 'Handling Events' guide.


How can I check the value of an item?

The value of any item can be checked by the get_value() method.


How can I create a custom database error message?

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")

How can I customize the content of a cell?

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' />")

In the sample above the grid will have a custom content - html input 'text'.

How can I filter data on the server side?

You have 3 ways to filter data on the server backend:

  • by specifying additional parameters in URL (on the client side)
  • by using in-header filter types during the component configuration (on the client side)
mygrid.setHeader("Column A, Column B");
function custom_filter($data){

See the guide 'Filtering' for more information.

How can I handle errors and log them?

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
$conn->enable_log("path to log file", true);// to show full info on the client side

How can I secure data exchange?

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'.

How can I set value to an item?

By using the set_value() method, you can set value to any item of a component.


How can I sort data on the server side?

You have 2 ways to sort data on the server backend:

  • by specifying additional parameters in URL (on the client side)
  • by using the sorting type 'connector' during the component configuration (on the client side)

For more information, see the 'Sorting' guide.

How can I validate data on client-side?

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.


How can I validate data on server-side?

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){

For more details on the server-side validation, see the 'Validation' guide.

Back to top