1

I'm trying to populate my treeview using the viewmodel:

VIEWMODEL:

var vm = {
        dragAndDrop: ko.observable(true),
        dataSource: getDataAPI(),
        dataTextField: "FullName"
    }

    return vm;

function getDataAPI() {
        var serviceRoot = "http://demos.kendoui.com/service";
        var homogeneous = new kendo.data.HierarchicalDataSource({
            transport: {
                read: {
                    url: serviceRoot + "/Employees",
                    dataType: "jsonp"
                }
            },
            schema: {
                model: {
                    id: "EmployeeId",
                    hasChildren: "HasEmployees"
                }
            }
        });
        return homogeneous;
    }

VIEW:

 <div data-bind="kendoTreeView: { dragAndDrop: dragAndDrop, dataSource: dataSource }"></div>

ERROR:

Unable to get value of the property 'toLowerCase'

SUMMARY: I am able to populate a tree if I use static json data, using this knockout method

Suresh Kamrushi
  • 15,627
  • 13
  • 75
  • 90
I Stand With Russia
  • 6,254
  • 8
  • 39
  • 67

1 Answers1

0

The problem is likely one of Kendo thinking your data is a string when it's a number or other type.

You may need to put a data-field attribute in your HTML. See this thread for more inforation.

Judah Gabriel Himango
  • 58,906
  • 38
  • 158
  • 212
  • Yea, I saw that thread also, but the error occurs because the dataset comes back null. Seems that kendo.data.HierarchicalDataSource isn't getting anything from the webservice – I Stand With Russia Mar 04 '13 at 19:02
  • Ok, if your HierarchicalDataSource is returning null, you should include that information in your question, because it suggests the problem has nothing to do with UI or JavaScript, and everything to do with your data service. – Judah Gabriel Himango Mar 04 '13 at 20:17
  • I just noticed the data service call is going out to the kendoui.com site. If you're running this locally or from a domain different than kendoui.com, you're likely going to get cross-site scripting errors. – Judah Gabriel Himango Mar 04 '13 at 20:18
  • I get the same problem with local data – I Stand With Russia Mar 05 '13 at 20:18