1

I have a data source coming from WebApi - please find below the JSON string - and I would like to display it in Kendo UI Treelist. I'm using the Angular version.

I have been try to figure out why it is not working for me for hours. The TreeList always says that "Request failed". There is something I cannot see yet. There is no error on the console, and I cannot debug because I'm using the minified version.

On the other hand I have a few questions:

  • Do I understand correctly that the Id, ParentId properties ind the schema describe the parent - child relation between the records?
  • If so, then the data I would like to hand over the TreeList should be a list of plain objects where: every item should contain an Id the ParentId data, or equivalent which can be mapped as it is described in the example.

Json from WebApi:

[{
    "Id": 10,
    "Name": "tiz",
    "ParentId": null
},
{
    "Id": 20,
    "Name": "husz",
    "ParentId": null
},
{
    "Id": 30,
    "Name": "harm",
    "ParentId": 10
},
{
    "Id": 40,
    "Name": "negyv",
    "ParentId": 20
}]

Angular code:

    function activate() {

        vm.treeOptions = {
            dataSource: {
                transport: {
                    read: {
                        url: configurationService.goNoGoWebApiRootUrl + 'WorkItemClassificationNode/Get2/Depth',
                        dataType: "jsonp"
                    },
                    parameterMap: function (options, operation) {
                        if (operation !== "read" && options.models) {
                            return { models: kendo.stringify(options.models) };
                        }
                    }
                },
                schema: {
                    model: {
                        id: "Id",
                        parentId: "ParentId",
                        fields: {
                            Id: { type: "number", editable: false, nullable: true },
                            ParentId: { type: "number", editable: false, nullable: true },
                            Name: { type: "string", editable: false, nullable: true }
                        }
                    }
                }
            },
            sortable: false,
            editable: false,
            columns: [
                {field: "Id", title: "Id", width: "150px"},
                {field: "Name", title: "Name", width: "500px"},
                {field: "ParentId", title: "ParentId", width: "100px"}
            ]
        }

    }
4

1 に答える 1