To define grid structure on the server side you can choose one of two ways:
The first case:
GridColumn column1 = new GridColumn(
String header,
String type,
String id,
int width,
String align,
String valign,
String sort,
String color,
Boolean hidden
);
GridColumn column2 = ...
GridConfiguration myConfig= new GridConfiguration();
myConfig.addColumn(column1);
myConfig.addColumn(column2);
The second case:
GridColumn column1 = new GridColumn();
GridColumn column2 = ...
column1.setHeader("Column1");
column1.setType("ed");
...
GridConfiguration myConfig= new GridConfiguration();
myConfig.addColumn(column1);
myConfig.addColumn(column2);
By using KeyGridConnector instead of GridConnector, you can load data from a table without identity field. In this case, any data field will serve as the identity one.
Connection conn = ( new DataBaseConnection()).getConnection();
KeyGridConnector data = new KeyGridConnector(conn);
data.render_table("mytable","name","name,address,phone");
For more details, see the 'KeyGridConnector' guide.
dhtmlxConnector contains a bit of methods that allow setting the appearance of a grid.
These methods can be divided into 2 groups:
for a cell customization:
for a row customization:
class RenderBehavior extends ConnectorBehavior{
public void beforeRender(DataItem data) {
if (data->get_index() % 2 == 1 )
data.set_row_color("red");
}
}
Connection res = ( new DataBaseConnection()).getConnection();
GridConnector grid = new GridConnector(res);
grid.event.attach(new RenderBehavior());
grid.render_table("grid50000","item_id","item_nm,item_cd");
Tips:
data.set_row_attribute("class","backrgroundclass");
.backrgroundclass{
background:red !important;
}
Back to top