SMART datagrid v.1 > Classes > TreeDataLoader
It reads text or JSON object or XML and adds to data rows of Data Set.
The way of proceeding data and the property which can be set in options are different depending on type. It will be described in the table below. Please refer to "Fill Mode" table about "fillMode", "fillPos" in options.
type | data | options |
---|---|---|
'csv' | text | 'start': The location of starting row which will be read as data. The default value is 0. 'count': The number of rows which will be read. If it is less than 0, it will be all rows from start. The default value is -1. 'delimiter': Field delimiter. The default value is ','. 'quoted': If it is true, when enclosed by '"'(Double quotation marks) or '''(Quotation marks), it will read after removing both ends. 'currency': If it is true, in the case of NUMBER field, it will read after removing strings except number, '.', '-', '+'. 'filter': filter expression which will be applied when loading. It will only read rows which have passed this expression. Please refer to Filter Variables below about variables which can be used in expression. Example) It will only read the row of which 'values['product_id'] like 'n%'' => product_id starts with 'n'. 'parentId': rowId of parent row of rows which will be added when fillMode is not 'set'. If do not specify, it will be added as the top row. 'treeField': The location in which contains the value to be used when determine tree hierarchy. 'needSorting': If it is true, before organizing the tree, it will sort all based on treeField. |
'json' | text | json | In the case of text, it will objectify by JSON.parse() first. 'rows': The location of data set which will be read as row from data. It is specified as path which has been separated by dot(.). 'parentId': It is the same as CSV item above. Please refer to Json Path table below. If do not specify, it will consider data as JSON array. 'filter': It is the same as CSV item above. |
'xml' | text | DOM | In the case of text, it will parse as XMLDocument object by using DOMParser or ActiveXObject first. 'parentId': It is the same as CSV item above. 'rows': The location of data set which will be read from data. It is specified as path which has been separated by dot(.). Please refer to Xml Path table below. If do not specify, it will consider data as JSON array. 'filter': It is the same as CSV item above. |
fillMode | Explanation |
---|---|
'set' | Fill after removing existing rows. |
'append' | Add after the last child row of row which has been specified by parentId. |
'insert' | Insert in the location of child row in fillPos location of row which has been specified by parentId. |
path | Explanation |
---|---|
'' | If do not specify or it is an empty string, it will read the original data as array. |
'row' | It reads 'row' property of original data as array. |
'prop.row' | It reads 'row' property of 'prop' property of original data as array. |
'prop[1].row' | 'prop' property of original data is an array, and it reads 'row' property of this second object as array. |
'$[0].row' | The original data is an array, and it reads 'row' property of this first object as array. |
path | Explanation |
---|---|
'' | If do not specify or it is an empty string, it cannot read as data rows. If do not specify, it will get elements of which name is 'row'. |
'row' | It reads the ones of which name is 'row' among top elements. |
'prop.row' | It reads the ones of which name is 'row' among child elements of the first element among top elements of which name is 'prop' as row. It is the same as specifying as 'prop[0].row'. |
'prop[1].row' | It reads the ones of which name is 'row' among child elements of the second element among top elements of which name is 'prop' as row. |
'$[0].row' | The original data is an array, and it reads 'row' property of this first object as array. |
Variable Name | Explanation |
---|---|
'no' | The location of original row which is being read. start value will be added. |
'row' | The number of data set row which is being appended or updated. |
'values' | The field value of original row. It is used with 'values['product_id']'. |
$('#load').click(function () {
$.getJSON('data/data.json', null, function (data) {
new DataLudi.DataLoader(dataset).load('json', data, {
fillMode: "append"
});
// Or, use total function.
DataLudi.loadJsonData(dataset, data, {
fillMode: "update",
fillPos: 10,
});
});
});