APPLICABLE TO: Grid, TreeGrid, Tree, Combo, Scheduler
When you need to update values which were returned from a database table or set some specific formatting before sending data to the client side, you should use the beforeRender event handler.
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");
APPLICABLE TO: Grid, TreeGrid, Tree, Combo, Scheduler
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>");
}
}
Connection res = ( new DataBaseConnection()).getConnection();
GridConnector grid = new GridConnector(res);
grid.event.attach(new RenderBehavior());
APPLICABLE TO: Grid, TreeGrid, Tree, Combo, Scheduler
More complex formatting rules can be defined by using extra fields during the configuration.
class RenderBehavior extends ConnectorBehavior{
public void beforeRender(DataItem data) {
//set row color
data.set_row_color(data.get_value("color"));
//save in userdata
data.set_userdata("some_data",data.get_value("count"));
}
}
Connection res = ( new DataBaseConnection()).getConnection();
GridConnector grid = new GridConnector(res);
grid.event.attach(new RenderBehavior());
grid.render_table("some_table","id","name,price","color,count");
APPLICABLE TO: Tree, TreeGrid
TreeGrid provides TreeGridDataItem and Tree provides TreeDataItem as the input parameter of the beforeRender event handler. Both of them support base operations and a few specific ones.
class RenderBehavior extends ConnectorBehavior{
public void beforeRender(DataItem data) {
TreeDataItem item = (TreeDataItem)data;
if (item.get_value("complete").equals("75"))
item.set_check_state(true);
if (item.get_value("duration").equals("10"))
item.set_image("true.gif");
else
item.set_image("false.gif");
}
}
tree.event.attach(new RenderBehavior());