dhtmlxconnector:data_management_how-tos_general [DHX documentation]

PHP Connector DHTMLX

General how-tos

How can I assign aliases to DB columns?

Using render_sql() or render_table() you can assign aliases to required tables or columns. To do this, in sql statement you should use word 'as' (as in any usual sql statement), in other parameters - parentheses.

$grid->render_sql("Select *,tableA.id as aid from tableA, tableB  where  tableA.id=tableB.id", "tableA.id(aid)","name,price(product_price)");

How can I attach event?

To attach event you should use event→attach(). For more details of this topic, see 'Event handling' quide.


How can I check value of an item?

Using get_value() method you can check value of any item.


How can I create 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 deny access to a certain operation?

By default, connector allows all operations. To deny some operation use deny(name_of_operation) method that can get one of the following:read/update/insert/delete. For more details see 'Security' guide.


How can I customize content of a cell?

You can use beforeRender event to define how 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 custom content - html input 'text'.

How can I filter data on server-side?

You have 3 ways to filter data on server backend:

  • by specifying additional parameters in URL (on client-side)

  • by using in-header filter types while component configuration (on client-side)

    mygrid.setHeader("Column A, Column B");
  • by means of beforeRender event (on server-side)

    function custom_filter($data){

See the guide 'Filtration' for more information.

How can I handle errors and log them?

You can enable logging using enable_log() method. For more details see 'Error handling and logging' guide.

$conn->enable_log("path to log file");// to show short info on client-side
$conn->enable_log("path to log file", true);// to show full info on client-side

How can I set value to an item?

Using set_value() method, you can set value to any item of component.


How can I sort data on server-side?

You have 2 ways to sort data on server backend:

  • by specifying additional parameters in URL (on client-side)

  • by using sorting type 'connector' while component configuration (on client-side)


See the guide 'Sorting' for more information.

How can I validate data on client-side

dataProcessor lets you validate data on client-side. Use 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 of server-side validation, see guide 'Validation'.