This is a migrated thread and some comments may be shown as answers.

Auto-generate IDs for local data

1 Answer 42 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 2
dandv asked on 04 Jan 2015, 12:23 PM
I have a tree where I know the first level of nodes, and want to load dynamically children of those nodes.

How can I create a DataSource based on local data, and not have to define IDs manually? It seems that IDs are mandatory for loading further remote data.

I'm coming from Webix, where you can simply write:

    view: 'tree',
    data: [
      { value: 'Programs',
      }, {
        value: 'Governance',
        data: [
          {value: 'Regulations'},
          {value: 'Policies'},
          {value: 'Standards'}
    on: {
      onItemClick: function (nodeId, el) {
           // nodeId is defined (automatically generated)
var node = this.getItem(nodeId);
        // will output the text of the clicked node
           // load children of node.value via AJAX here...

With Kendo UI, if I don't define IDs, it seems there's no way to distinguish in the function between returning the first-level nodes from the local data, and loading child nodes of one of the first-level nodes:

var myHDS = new{
    transport: {
        read: function (options) {
            if  (! {
                    { ... hard-coded local data for the first level of nodes
                             ... must hard-code IDs?
                // must have an id here
            var node = myHDS.get(;
            // load children from the sever via AJAX call

1 Answer, 1 is accepted

Sort by
Alex Gyoshev
Telerik team
answered on 07 Jan 2015, 08:49 AM

Hello Dan,

You can define the value field as the id field for the first level, and use a different one for sub-levels

schema: { model: {
    id: "value",
    children: { schema: { model: { id: "anotherField" } } }
} }

Alex Gyoshev
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Data Source
Asked by
Top achievements
Rank 2
Answers by
Alex Gyoshev
Telerik team
Share this question