Pro*_*gle 1 transport kendo-ui
使用Kendo.web.js版本2013.2.716和2012.3.1315,我试图在transport.create中使用一个函数而不是调用URL.我发现这个函数没有被调用.相反,调用默认URL并且生成的HTML似乎会导致kendo的内容出错,因为它应该是JSON.
我认为这是某种类型的配置错误,但我无法弄清楚问题出在哪里.
以下是代码片段:
var clientListDS = new kendo.data.DataSource({
transport: {
read: {
url: window.baseUrl + 'HealthCheck/ClientSummary',
dataType: 'json',
type: 'POST'
},
create: function(a,b,c) { alert('Create'); },
createY: window.baseUrl + 'HealthCheck/DontCallMe',
createX: {
url: window.baseUrl + 'HealthCheck/DontCallMe',
dataType: 'json',
type: 'POST'
},
whatWeWantCreateToDo: function () {
showChooseDialog('Some Random String', 'Select Client', OnRefreshInactiveClientList);
},
destroy: function () {
alert('destroy');
},
update: function () {
alert('update');
}
},
autoSync: true,
schema: {
model: {
id: 'ID',
fields: {
ID: { required: false, type: 'number', nullable: true },
ClientName: { type: 'string' },
ClientTag: { type: 'string' },
Status: { type: 'string' }
}
}
}
});
Run Code Online (Sandbox Code Playgroud)
然后我使用生成的数据源来构建这样的网格:
$('#cClientGrid').kendoGrid({
dataSource: clientListDS,
columns: [
{ field: 'ClientTag', title: 'Tag'},
{ field: 'ClientName', title: 'Name' },
{ field: 'Status' }
],
editable: {
mode: 'incell',
createAt: 'bottom'
},
edit: function (pEvent) {
if (pEvent.model.isNew())
alert('create');
else
alert('Edit');
},
toolbar: ['create']
});
Run Code Online (Sandbox Code Playgroud)
一些值得注意的行为:
任何关于我如何能够调用函数而不是URL的想法或见解将不胜感激.
首先使transport
所有内容成为URL或函数,不要混淆它们.
如果您需要实现read
一个功能,您只需:
transport: {
read : function (options) {
$.ajax({
url: window.baseUrl + 'HealthCheck/ClientSummary',
dataType: 'json',
type: 'POST',
success : function (result) {
options.success(result);
}
});
},
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5380 次 |
最近记录: |