gpt4 book ai didi

kendo-ui - 如何在 kendo.data.Datasource 上获取单个结果

转载 作者:行者123 更新时间:2023-12-02 16:57:14 28 4
gpt4 key购买 nike

我有这样的 Odata 结果

        {"odata.metadata":"https://localhost/DocTalkMobileWebApiOData/odata/$metadata#MasterPatient/@Element","PatUniqueId":"39e713db-6a0e-4e59-bf7b-033f4fc47ad5",  "PatID":null,
"pat_lname":"White","pat_fname":"Peter","pat_mi":" ","pat_ssn":"270787655","pat_dob":"08/07/1973","pat_sex":"M","pat_status":null,"priInsID":2,"secInsID":1,"PCPID":1,"InternalDrID":1,"EXPID":1,"EXPDate":"","pat_phone":null,"isNew":true,"imported":true,"byWhom":"dt","lastUpdate":"2011-03-30T09:41:57.36","changeStamp":"AAAAAAAAIUE=","address":"","city":"","state":"","zip":"","currentMcp":"","currentVisitCount":-2,"otherId":"543674","pcpName":null,"hasChanges":true,"ProgramSource":null,"mrnID":"","createdBy":null,"createdDate":"2007-10-26T10:16:15","expLocation":null,"ethnicId":1,"prefLanguageId":1,"raceId":1
}

我尝试通过 kendo.ui.datasource 获得此结果:

 newPatient = new kendo.data.DataSource({
type: 'odata', // <-- Include OData style params on query string.
transport: {
read: {
url: url + '/MasterPatient(guid\'00000000-0000-0000-0000-000000000000\')', // <-- Get data from here
dataType: "json" // <-- The default was "jsonp"
},

parameterMap: function (options, type) {
var paramMap = kendo.data.transports.odata.parameterMap(options);

delete paramMap.$inlinecount; // <-- remove inlinecount parameter.
delete paramMap.$format; // <-- remove format parameter.

return paramMap;
}
},
schema: {
data: function (data) {
return data;
},
total: function (data) {
return data['odata.count']
},
}
});
newPatient.fetch(function () {
kendo.bind($('#newPatientTab'), newPatient);
});

但不知道为什么它总是抛出错误:

Uncaught TypeError: Object [object global] has no method 'slice' 

请帮助我。谢谢

最佳答案

在 Kendo UI 中,DataSource 仅适用于数组。如果您可以更改服务器响应以发送类似的内容

[{"odata.metadata":"https://localhost/DocTalkMobileWebApiOData/odata/$metadata#MasterPatient/@Element","PatUniqueId":"39e713db-6a0e-4e59-bf7b-033f4fc47ad5","PatID":null,"pat_lname":"White","pat_fname":"Peter","pat_mi":"     ","pat_ssn":"270787655","pat_dob":"08/07/1973","pat_sex":"M","pat_status":null,"priInsID":2,"secInsID":1,"PCPID":1,"InternalDrID":1,"EXPID":1,"EXPDate":"","pat_phone":null,"isNew":true,"imported":true,"byWhom":"dt","lastUpdate":"2011-03-30T09:41:57.36","changeStamp":"AAAAAAAAIUE=","address":"","city":"","state":"","zip":"","currentMcp":"","currentVisitCount":-2,"otherId":"543674","pcpName":null,"hasChanges":true,"ProgramSource":null,"mrnID":"","createdBy":null,"createdDate":"2007-10-26T10:16:15","expLocation":null,"ethnicId":1,"prefLanguageId":1,"raceId":1}]

然后就可以正常工作了。注意:它是数组格式。

或者

您可以在客户端将单个对象包装到架构的数据函数内部的数组中。

schema: {
data: function(server-response) {
return [server-response];
}
}

Kendo 团队应该在良好的文档上投入更多时间。

关于kendo-ui - 如何在 kendo.data.Datasource 上获取单个结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19570655/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com