If use TreeDataLoader.load, you can load the source data of different formats imported from the server to TreeDataSet.
new TreeDataLoader(dataSet).load('csv', data, {
start: 1,
quoted: true,
...
});
First, load method specifies the data format. Currently, it supports 'csv', 'json', 'xml'. data is a source data, and it can be a string or JSON object or XML document object depending on the format specified in the first parameter.
New rows will be created after removing all of the existing data rows, and onRowCountChanged event will be fired after the loading is completed.
As in the format below, it gets the stored CSV file from the server and configures Tree Data Set. Since the field names are set in the first row, start of the load option will be 1. Also, quoted will be specified as true since the fields with the quoted values already exist, and currency will be specified as true since the text rather than the number is contained in the value of NUMBER field. Please refer to TreeDataLoader.load topic about more details on the values that can be specified in the option.
treeField and useTreeField are the important options, and treeField is 1 since the tree information is contained in the second field and useTreeField is false so that these field values will not be saved in the data set. Please refer to load topic about more details.
Read the text file saved as CSV format.
In order to load JSON array as below to the data set, you should specify the type as "json" first and specify rows and childRows options. rows specify which objects should be imported to the top row, and childRows specify which property contains the array of the child row after that. In this example, rows will be specified as an empty string so that the top item of the array can be created as the top rows of the data set, and childRows will be specified as "rows" so that json array specified by "rows" property can be imported to child rows.
Please refer to TreeDataLoader.load topic about more details of the properties.
Read the text file saved as JSON format.
In order to load the data transferred as an XML text file to the tree data set as below, you should specify the type as "xml" first and specify rows and childRows options. The property name is the same as the case of JSON, but the instruction is different.
The rows are the tag name of the XML elements to be imported to the data row. In the example below, it is row. The childRows are the tag name of the element which contains the elements to import the child rows. In the example, it is rows. This property may not be specified when the top element containing child elements does not exist, and the elements specified by rows are contained in it right below.
Please refer to TreeDataLoader.load topic about more details of the properties.
Read the text file saved as XML format.