Pass kendo grid model in Ajax call

▼魔方 西西 提交于 2020-01-07 03:50:20

问题


I need to pass kendo grid model (on save event) to the server side in an ajax call. How can i do that? Tried the following

function onSave(e) {

var keys = Object.keys(e.values);
    var colName = keys[0];
    var alignment;
    var mapHeaderId = $('#ddlMaps').val();
    var yearId = $('#ddlYear').val();

$.get("@Url.Action("CalculateFormattingForResult", "Maps")", { studentId: e.model.studentid, colId: colName, value: e.values[colName], mapHeaderId: mapHeaderId, yearId: yearId,
                                                                    model: JSON.stringify(e.model)
    }, function (data) {}
}

My C# code is

public string CalculateFormattingForResult(int studentId, string colId, string value, int mapHeaderId, int yearId, string model) {
}

If someone is interested into why i am doing that..is because i need to get the latest edited values in the grid based on which i have to calculate/update other values in the grid.

UPDATE

I tried it with $.post and it worked but with post the problem is that probably i can only submit the form once however, i am only doing data validation on edit event of each cell...so i need to do it again and again. so my question is still there... how do i pass json string which is [kendo dataItem (row)] in ajax??


回答1:


The problem was i had to put a $.post instead of $.get..found answer here:passing json in ajax

Also, as I mentioned in update, second time kendo grid model changes like this

originaljson + edited values as json

for example: firstname:"samra", surname:"abc" becomes firstname:"samra", surname:"abc" , firstname:"sarah", surname:"xyz"

In my case the newer values contained html divs (to format cells), so it was not getting posted!.



来源:https://stackoverflow.com/questions/44773514/pass-kendo-grid-model-in-ajax-call

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!