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

Defining TreeView DataSource as XML

1 Answer 108 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
OnaBai
Top achievements
Rank 2
OnaBai asked on 03 Apr 2013, 02:31 PM
Today I've noticed that when using an XML DataSource in a TreeView, KendoUI complains about level method not being defined.

As far as I've seen this method is defined in Data Model but seems that for XML DataSources the code follow a different path and level is not defined.

Given the XML:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
    <doc>
        <nome>fabio</nome>
    </doc>
    <doc>
        <nome>mauro</nome>
    </doc>
</root>
And the following JavaScript code for defining the grid and the datasource:
var ds = new kendo.data.HierarchicalDataSource({
    transport: {
        read: {
            url     : "kendoTWData.xml",
            dataType: "xml"
        }
    },
    schema   : {
        type : 'xml',
        data : '/root/doc',
        model: {
            fields: {
                nome: "nome/text()"
            }
        }
    }
});
 
$("#treeview").kendoTreeView({
    dataSource   : ds,
    dataTextField: "nome"
});
 It complains about level not being defined.

If I add into the model a level function returning any number then it works.
model: {
    fields: {
        nome: "nome/text()"
    },
    level : function () {
        return 0;
    }
}
Is this a bug or XML datasources are not supported in Kendo UI TreeView widgets?

1 Answer, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 05 Apr 2013, 02:03 PM
Hello Emiliano,

The HierarchicalDataSource, and the TreeView widget that uses it, do not support binding to XML at this time. Feel free to log a feature request on uservoice.

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