I have a Kendo ListView. This is populated with data from a Kendo DataSource.
This is my ListView:
$("#lvCodeLeft").kendoListView({
dataSource: dsCodeLeft,
template: "<div><b>#:code#</b> #:heading#</div>",
selectable: "multiple"
});
And here is my DataSource:
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" }}
});
I have a normal button that calls a javascript function
<input id="btnAssign" type="button" value=">>" onclick="assignCode()">
Here is the assignCode() function (first version):
function assignCode() {
dsCodeLeft.fetch(function () {
this.read();
var atc = this.at(0);
this.at(0).set("primaryUser", 2);
this.sync();
});
};
And I have also tried (second version):
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();
});
};
But no mather what I do, the parameters send to the webservice is null. The webservice is expecting an Code[], where Code is:
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; }
}
I think that my problem is with the DataSource' parameterMap, but I can't figure it out.