There are three possible approaches to load additional data:
It is possible to define a column as hidden - in such case, it will not be visible for a user, but it will be accessible by API. So it will be possible to take the data from it.
In case of initialization from JS code, the user should write the following:
//... grid.init(); grid.setColumnHidden(index,true); // indicate column index and set the state to true to hire the column
In case of initialization from XML, the syntax will be like this:
<rows> <head> <column hidden="true">Dummy</column> ...
The data can be accessed as data of any other columns:
grid.cells(i,j).getValue(); grid.cells(i,j).setValue(some);
Data of a hidden column is included in the serialization by default, and can't be controlled by setSerializableColumns() command. This data is available during dataprocessor calls
UserData is a special tag that can be:
UserData can be set in XML in the following way:
<?xml version='1.0' encoding='iso-8859-1'?> <rows> <userdata name="somName1">some data</userdata> <row id="unique_rowid"> <userdata name="someName1"> some row data </userdata> <userdata name="someName2"> some row data </userdata> <cell>cell content</cell> <cell><![CDATA[<font color="red">cell</font> content]]></cell> </row> </rows>
The following methods are used for this purpose:
var userdata = grid.getUserData("","someName1"); // some data grid.setUserData("","someName1","new value");
The following methods are used in the code sample above:
Row-related UserData can be accessed like this:
var userdata = grid.getUserData("unique_rowid","someName1"); // some row data grid.setUserData("unique_rowid","someName1","new value");
UserData may be included in the serialization process using setSerializationLevel() command (it is disabled by default).
This data is available during dataprocessor calls.
dhtmlxgrid 1.6+ allows accessing any attribute of row or cell tag programmatically when loading from XML:
<?xml version='1.0' encoding='iso-8859-1'?> <rows> <row id="unique_rowid" some="data"> <cell some="data">cell content</cell> </row> </rows>
The following methods are used to access row attributes:
var rowAttr = grid.getRowAttribute("unique_rowid","some"); grid.setRowAttribute("unique_rowid","some","new value");
To access cell attributes, the following code lines should be used:
grid.cells(i,j).getAttribute("some"); grid.cells(i,j).setAttribute("some","new value");
If the user wants to include such custom attributes in the serialization, some special steps are required:
grid.xml.row_attrs.push("some"); // will include some attribute of a row in the serialization grid.xml.cell_attrs.push("some"); // will include some attribute of a cell in the serialization
Note: This data is not available during dataprocessor calls.