This is a migrated thread and some comments may be shown as answers.

How does "parametermap" code get executed?

3 Answers 270 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Support
Top achievements
Rank 1
Support asked on 11 Sep 2013, 08:20 PM
Hi,

I am trying to enable inline editing for the KendoUI grid with an autocomplete control. I want to be able to post the edited model data into a controller action, however my parametermap code never gets executed. Can someone please explain what causes the parametermap code to get executed?

Here is my dataSource declaration:
var battingDataSource = new kendo.data.DataSource({
    schema: {
        model: {
            id: "PlayerId",
            fields: {
                PlayerId: { editable: false, nullable: true },
                PlayerFullName: { validation: { required: true } },
                BattingOrder: { type: "number", validation: { required: true, min: 1, max: 11 } },
                RunsScored: { type: "number", validation: { required: true, min: 0 } },
                BallsFaced: { type: "number", validation: { required: true, min: 0 } },
                Fours: { type: "number", validation: { required: true, min: 0 } },
                Sixes: { type: "number", validation: { required: true, min: 0 } },
            }
        }
    },
    batch: true,
    transport: {
        create: {
            url: "/MatchPlayer/Create",
            type: "POST"
        },
        update: {
            url: "/MatchPlayer/Update",
            type: "POST"
        },
        read: {
            url: "/MatchPlayer/Read",
            type: "POST"
        },
    },
    parameterMap: function (data, operation) {
        alert("hit");
        if (operation != "read") {
            // post the players so the ASP.NET DefaultModelBinder will understand them:
 
            var result = {};
 
            for (var i = 0; i < data.models.length; i++) {
                var player = data.models[i];
 
                for (var member in player) {
                    result["players[" + i + "]." + member] = player[member];
                }
            }
 
            return result;
        }
    }
});

3 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 12 Sep 2013, 09:19 AM
Hello,

There is syntax mistake in the provided code - parameterMap function should be nested in transport object. Please correct it.
transport: {
    create: {
        url: "/MatchPlayer/Create",
        type: "POST"
    },
    update: {
        url: "/MatchPlayer/Update",
        type: "POST"
    },
    read: {
        url: "/MatchPlayer/Read",
        type: "POST"
    },
    parameterMap: function(data, operation) { /* your code */ }
},


Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Support
Top achievements
Rank 1
answered on 23 Sep 2013, 07:27 PM
Hi,

Thank you for your help. I have it all working now :)
0
Yaroslav
Top achievements
Rank 1
answered on 02 Apr 2020, 09:21 AM
thanks! Helped a lot!
Tags
Grid
Asked by
Support
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Support
Top achievements
Rank 1
Yaroslav
Top achievements
Rank 1
Share this question
or