私は剣道リストビューを持っています。これには、Kendo DataSource からのデータが取り込まれます。
これは私のリストビューです:
$("#lvCodeLeft").kendoListView({
dataSource: dsCodeLeft,
template: "<div><b>#:code#</b> #:heading#</div>",
selectable: "multiple"
});
そして、ここに私のデータソースがあります:
var dsCodeLeft = new kendo.data.DataSource({
batch: true,
transport: {
read: {
cache: false,
url: "http://localhost:9995/server/Service.svc/GetUnasignedCodes",
dataType: "jsonp"
},
update: {
url: "http://localhost:9995/server/Service.svc/UpdateCodes",
dataType: "json",
contentType: "application/json; charset=utf-8",
type: "POST"
},
parameterMap: function(data, type) {
if (type == "update") {
return { models: kendo.stringify(data.models) };
}
}
},
schema: { model: { id: "id" }}
});
JavaScript関数を呼び出す通常のボタンがあります
<input id="btnAssign" type="button" value=">>" onclick="assignCode()">
これが assignCode() 関数です (最初のバージョン):
function assignCode() {
dsCodeLeft.fetch(function () {
this.read();
var atc = this.at(0);
this.at(0).set("primaryUser", 2);
this.sync();
});
};
そして、私も試しました(2番目のバージョン):
function assignCode() {
dsCodeLeft.fetch(function () {
this.read();
this.pushUpdate({ id: "61078", primaryUser: 2 }); //61078 is the first record
this.at(0).dirty = true;
this.sync();
});
};
しかし、私が何をしても、Webサービスに送信されるパラメーターはnullです。Web サービスは Code[] を予期しています。Code は次のとおりです。
public partial class Code
{
public string id { get; set; }
public string code { get; set; }
public string heading { get; set; }
public Nullable<System.DateTime> deleteDate { get; set; }
public string comment { get; set; }
public Nullable<decimal> primaryUser { get; set; }
}
私の問題は DataSource の parameterMap にあると思いますが、わかりません。