SMART datagrid v.1 > Classes > TreeDataSet
It removes all existing rows and adds values which have been transferred by parameter rows as Data Rows.
Each row of rows can be an array in which has stored values according to field order or JSON object of which field names are property.
When organize the tree, it will convert and add as Data Rows in order from the first row of rows. At this point, the value of location specified by treeField will become the value of determining tree hierarchy. In other words, if treeField field value of the current converting row is the value starting from the value of previous row, it will become the child row of previous row.
If do not specify useTreeField as true, the values of location which has been specified by treeField will not be added to data set. When DataSet.setFields, you should ignore treeField location and add fields. If want to use it as field value, you should specify useTreeField as true, and add the field to treeField location when DataSet.setFields.
If rows have not been sorted according to treeField, you should do sorting first by specifying sortRows as true.
// treeField: 0, useTreeField: false
var rows = [
['0', 'name1', 'value'1],
['0.1', 'name11', 'value'11],
['0.2', 'name12', 'value'12],
];
// Use from the second item of each array of rows as a value.
ds.setFields([{
fieldName: 'name'
}, {
fieldName: 'value'
}]);
ds.setRows(rows, 0);
// treeField: 0, useTreeField: true
var rows = [
['0', 'name1', 'value'1],
['0.1', 'name11', 'value'11],
['0.2', 'name12', 'value'12],
];
// Add tree field
ds.setFields([{
fieldName: 'tree'
}, {
fieldName: 'name'
}, {
fieldName: 'value'
}]);
ds.setRows(rows, 0, true);