我是剑道新手。我遇到了模型绑定问题。当我使用 firebug 进行调试时,它显示options.models is undefined。由于这个原因,parameterMap 中的“if”条件始终为 false,并且网格不会填充数据。 但是当我删除 parameterMap 部分时,它可以工作。 我认为,如果有人可以解释kendo dataSource 中的参数映射,那将非常有帮助。谢谢你。
function GetDataSource() {
var PrjKy = $("#cmbPrjNm").val();
if (PrjKy == "") { PrjKy = 1; }
var PrcsDetKy = 1;
if (PrcsDetKy == "") { PrcsDetKy = 1; }
var PrcsTypKy = $("#toDotype").val();
if (PrcsTypKy == "") { PrcsTypKy = 1; }
var AprPrtyKy = $("#cmbPiority").val();
if (AprPrtyKy == "") { AprPrtyKy = 1; }
var AprStsKy = $("#status").val();
if (AprStsKy == "") { AprStsKy = 1; }
var OrginAdrKy = 1;
if (OrginAdrKy == "") { OrginAdrKy = 1; }
var AprUsrKy = 1;
if (AprUsrKy == "") { AprUsrKy = 1; }
var NxtActByAdrKy = $("#cmbEmployee").val();
if (NxtActByAdrKy == "") { NxtActByAdrKy = 1; }
var FrmNxtActEntDt = $("#FrmNextActEnt").val();
var ToNxtActEntDt = $("#ToNextActEnt").val();
var FrmNxtActDt = $("#rcdDt").val();
var ToNxtActDt = $("#toDt").val();
var FrmInsertDt = $("#insrtDt").val();
var ToInsertDt = $("#InsrtToDt").val();
var dataSource = new kendo.data.DataSource({
transport: {
read: {
url: '@Url.Content("~/User/GetAllToDo")',
data: {
'PrjKy': PrjKy,
'PrcsDetKy': PrcsDetKy,
'PrcsTypKy': PrcsTypKy,
'AprPrtyKy': AprPrtyKy,
'AprStsKy': AprStsKy,
'OrginAdrKy': OrginAdrKy,
'AprUsrKy': AprUsrKy,
'NxtActByAdrKy': NxtActByAdrKy,
'FrmNxtActEntDt': FrmNxtActEntDt,
'ToNxtActEntDt': ToNxtActEntDt,
'FrmNxtActDt': FrmNxtActDt, //changed on 2013-8-30
'ToNxtActDt': ToNxtActDt, //changed on 2013-8-30
'FrmInsertDt': FrmInsertDt, //changed on 2013-8-30
'ToInsertDt': ToInsertDt//changed on 2013-8-30
},
dataType: "json"
},
update: {
url: "~/Home/UpdateToDo",
contentType: 'application/json; charset=utf-8',
dataType: "json",
type: "POST"
},
create: {
url: '@Url.Content("~/Home/UpdateToDo")',
contentType: 'application/json; charset=utf-8',
dataType: "json",
type: "POST"
},
destroy: {
url: '@Url.Content("~/User/DeleteToDo")',
contentType: 'application/json; charset=utf-8',
dataType: "json",
type: "POST"
},
parameterMap: function (options, operation) {
if (operation !== "read" && options.models) {
return JSON.stringify({ models: options });
}
}
},
pageSize: 10
, schema:
{
model:
{
id: "PrcsDetKy", //Primary key to uniquely identify the row.
fields: //Relavent fields of the grid should be bind with following model items
{
ID: { editable: false, nullable: false },
NxtActEntDt: { editable: true, nullable: false, validation: { required: true} },
AprPrty: { editable: true, nullable: false, validation: { required: true} },
AprUsr: { editable: true, nullable: true },
AprSts: { editable: true, nullable: true },
AprStsKy: { editable: true, nullable: true },
AprPrtyKy: { editable: true, nullable: true },
AprUsrKy: { editable: true, nullable: true },
AprResnKy: { editable: true, nullable: true },
PrjId: { editable: true, nullable: true },
TaskId: { editable: true, nullable: true },
TaskNm: { editable: true, nullable: false }, //validation: { required: true}
PrcsDetKy: { editable: false, nullable: false },
TaskTyp: { editable: true, nullable: false },
PrcsTypKy: { editable: true, nullable: true },
PrjKy: { editable: true, nullable: true },
PrcsDetAprKy: { editable: true, nullable: true },
PrjNm: { editable: true, nullable: false, validation: { required: true} },
Des: { editable: true, nullable: false },
NxtActByAdr: { editable: true, nullable: false, validation: { required: true} },
NxtActByAdrKy: { editable: true, nullable: true },
NxtActDt: { editable: true, nullable: true },
Rem: { editable: true, nullable: true, type: "string" },
OriginBy: { editable: false, nullable: true },
Hyperlinks1: { editable: false, nullable: true },
Hyperlinks2: { editable: false, nullable: true },
Hyperlinks3: { editable: false, nullable: true },
Hyperlinks4: { editable: false, nullable: true },
OrginAdrKy: { editable: true, nullable: true },
WrkStnKy: { editable: true, nullable: true },
ObjKy: { editable: true, nullable: true },
ObjCd: { editable: true, nullable: true },
ObjNm: { editable: true, nullable: true },
ItmKy: { editable: true, nullable: true },
ItmCd: { editable: true, nullable: true },
IsAct: { editable: true, nullable: true },
IsApr: { editable: true, nullable: true },
OrgEntDt: { editable: true, nullable: true }
}
}
}
});
return dataSource;
}