treeview works in local json data, not remote data why?

1 posts, 0 answers
  1. max
    max avatar
    1 posts
    Member since:
    Aug 2012

    Posted 13 Aug 2012 Link to this post

    I had a treeview, I got the json data from server side, and tried to bind it to treeview, but it didn't work, return all "undefined", but the same data I copied them into local, then hard code them into the treeview, it work fine, why ?

     1) below is my code.
    <script type="text/javascript">
        $(function () {
            $.getJSON('@Href("~/api/TrackingCodes/action/GetPageTree/?orgID=17&typeIds={\"1\", \"2\", \"10\"}")', function (ret) {
                var Sitetrees = new kendo.data.HierarchicalDataSource({
                    data: ret,
                    schema: {
                        model: {
                            id: "Value",
                            children: "Node"
                        }
                    }
                });
                $("#DivPageTree").kendoTreeView({
                    dataSource: Sitetrees,
                    dataTextField: "Text"
                });
            })
        })
    </script>



    2) It works when I copied these data into local

    <script type="text/javascript">
                 var Sitetrees = new kendo.data.HierarchicalDataSource({
                    data: [...................],
                    schema: {
                        model: {
                            id: "Value",
                            children: "Node"
                        }
                    }
                });
                $("#DivPageTree").kendoTreeView({
                    dataSource: Sitetrees,
                    dataTextField: "Text"
                });
    </script>
Back to Top