By using the render_sql() or render_table() methods you can assign aliases to the required tables or columns. For this purpose, in sql statement you should use 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),other"
);
To attach event you should use component.event.attach(). For more details on this topic, see the 'Handling Events' guide.
class CustomBehavior extends ConnectorBehavior{
@Override
public void beforeUpdate(DataAction data) {
//any custom code
}
}
component.event.attach(new CustomBehavior());
With the help of the get_value() method you can check the value of any item.
grid.get_value(name);
By default, the connector allows all operations. To deny some operation use the deny(name_of_operation) method that can get one of the following params:read/update/insert/delete. For more details see the 'Security' guide.
grid.access.deny(OperationType.Read);
You can use the beforeRender event to define how the content of a cell must be formatted.
class RenderBehavior extends ConnectorBehavior{
public void beforeRender(DataItem data) {
String field = data.get_value("some");
data.set_value("some","<a href='details.php?id="+field+"'>"+Details+"</a>");
}
}
grid = new GridConnector(res);
grid.event.attach(new RenderBehavior());
In the sample above, the grid will have a custom content.
You have 2 ways to filter data on the server backend:
mygrid.setHeader("Column A, Column B");
mygrid.attachHeader("#connector_text_filter,#connector_select_filter");
class FilterBehavior extends ConnectorBehavior{
@Overrride
public void beforeRender(DataItem data){
if (data.get_value("some") < 0 )
data.skip();
}
}
conn.attach.event(new FilterBehavior());
See the guide 'Filtration' for more information.
You can enable logging using the enable_log() method. For more details see the 'Error handling and logging' guide.
gridConn.enable_log("path");//to show short info on the client side
//or
gridConn.enable_log("path",true);// to show full info on the client side
By means of using the set_value() method, you can set a value to any item of 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);
See the guide 'Sorting' for more information.
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:
class validateBehavior extends ConnectorBehavior{
...
}
conn.event.attach(new validateBehavior());
For more details on the server-side validation, see the 'Validation' guide.
Back to top