[英]Why this Kendo UI Treelist - angular version - does not work?
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 . 我有一个来自WebApi的数据源-请在JSON字符串下面找到-我想在Kendo UI Treelist中显示它。 I'm using the Angular version.
我正在使用Angular版本。
I have been try to figure out why it is not working for me for hours. 我一直试图弄清楚为什么它对我几个小时不起作用。 The TreeList always says that "Request failed".
TreeList总是说“请求失败”。 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: 另一方面,我有几个问题:
Json from WebApi : 来自WebApi的Json :
[{
"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"}
]
}
}
After a 1-2 hour long investigation figured out that the datatype parameter - " jsonp " in the example above - is not correct because my service returns json " application/json ". 经过1-2小时的长时间调查后,发现上面示例中的数据类型参数-“ jsonp ”不正确,因为我的服务返回了json“ application / json ”。
The investigation required the kendo-ui-demos-service project installed in order to see how it works. 该调查需要安装kendo-ui-demos-service项目,以查看其工作方式。 It returns " application/x-javascript " datatype.
它返回“ application / x-javascript ”数据类型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.