在Ajax调用中传递kendo网格模型 [英] Pass kendo grid model in Ajax call

查看:84
本文介绍了在Ajax调用中传递kendo网格模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在ajax调用中将kendo网格模型(在保存事件中)传递到服务器端.我怎样才能做到这一点?尝试了以下

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) {}
}

我的C#代码为

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.

更新

我用$ .post尝试了一下,它起作用了,但是用post的问题是可能我只能提交一次表单,但是,我只在每个单元格的编辑事件上进行数据验证...所以我需要做一遍又一遍.所以我的问题仍然存在...我如何在ajax中传递[kendo dataItem(row)]的json字符串?

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??

推荐答案

问题是我不得不在这里放置$ .post而不是$ .get..found答案:

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

原始json +修改后的值作为json

originaljson + edited values as json

例如:名字:"samra",姓:"abc" 变成名字:"samra",姓:"abc",名字:"sarah",姓:"xyz "

在我的情况下,较新的值包含html div(用于格式化单元格),因此不会被发布!.

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

这篇关于在Ajax调用中传递kendo网格模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆