Defining TreeView DataSource as XML

2 posts, 0 answers
  1. OnaBai
    OnaBai avatar
    55 posts
    Member since:
    Aug 2012

    Posted 03 Apr 2013 Link to this post

    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?
  2. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 05 Apr 2013 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
Back to Top