0

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.

Wessel
  • 1
  • What do you need to send in the update request? – OnaBai Aug 07 '14 at 15:35
  • The ListView is populated with Code objects, and the update webservice expects an array of those Code objects. But basically I just need to set the primaryUser on the object – Wessel Aug 08 '14 at 07:28
  • You need to define the schema.model with all the properties in the Class Code – cwishva Aug 15 '14 at 11:06

0 Answers0