如何从jqgrid向控制器发送数据 [英] how to send data to controller from jqgrid

查看:93
本文介绍了如何从jqgrid向控制器发送数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ASP.Net MVC,并在页面上放置了一个jqgrid.我的jqgrid的数据源是一个xml文件.我已经从源xml填充了一个数据表,然后将该数据表转换为JSonObject来填充我的jqgrid.我知道可以用更好的方法来完成它,但是现在我只需要以这种方式应用它..
在jqgrid中,我为每一列启用了editmode,以便用户可以单击一行并在那里编辑数据.现在,我需要通过将其发送到某些控制器方法(如SaveData())来保存该数据,然后再使用DOM对象将其保存回xml.谁能告诉我如何发送此数据?使用哪个事件?我真的需要在这里使用clientArray吗?
这是我的代码...

I am using ASP.Net MVC and placed a jqgrid on my page. The data source for my jqgrid is a xml file. I have populated a datatable from source xml and then converted this datatable into JSonObject to fill my jqgrid. I know it can be done in better ways but for now I have to apply it this way only..
In the jqgrid, I have enabled editmode for each column so that user can click on a row and edit the data there itself. Now, I need to save this data back by sending it to some controller method like SaveData() which will then save it back to xml using DOM objects. Can anyone please tell me how to send this data? using which events? Do I really need to use clientArray here?
Here is my code ...

var lastSel;
$("#list1").jqGrid({
url: ''/CMS/GetCustomerData/5001'',
datatype: ''json'',
mtype: ''GET'',
height: ''150'',
rownumbers: true,
colNames: [''id'', ''name'', ''company''],
colModel: [
            { name: ''id'', index: ''id'', editable: false, sortable: true, width: 20, align: ''left'' },
        { name: ''name'', index: ''name'', editable: true, edittype: ''text'', sortable: true, search: true, width: 50, align: ''left'' },
        { name: ''company'', index: ''company'', editable: true, edittype: ''text'', sortable: true, search: true, width: 50, align: ''left'' }],
            pager: jQuery(''#pager''),
            viewrecords: false,
            imgpath: ''/Content/Default/UIComponents/css/redmond/images'',
            caption: "Customer details",
            width: 900,
            hidegrid: false,
            multiselect: false,
            altRows: true,
            altclass: ''altRow'',
            onSelectRow: function(id) {
                if (id && id !== lastSel) {
                    jQuery("#list1").saveRow(lastSel, true, ''clientArray'');
                    jQuery("#list1").editRow(id, true);
                    lastSel = id;
                }
            }
        });
    });

推荐答案

(#list1").jqGrid({ 网址:"/CMS/GetCustomerData/5001", 数据类型:"json", mtype:"GET", 高度:``150'', 行号:true, colNames:["id",名称",公司"], colModel:[ {名称:"id",索引:"id",可false,可排序:true,宽度:20,对齐:"left")}, {名称:名称",索引:名称",可true,可编辑类型:文本",可排序:true,搜索:true,宽度:50,对齐:"left"}}, {名称:公司",索引:公司",可true,编辑类型:文本",可排序:true,搜索:true,宽度:50,对齐:"left"}] , 传呼机:jQuery(''#pager''), 查看记录:错误, imgpath:``/Content/Default/UIComponents/css/redmond/images'', 标题:客户详细信息", 宽度:900, hidegrid:错误, 多选:false, altRows:是的, altclass:"altRow", onSelectRow:function(id){ 如果(id& id!== lastSel){ jQuery(#list1").saveRow(lastSel,true,``clientArray''); jQuery(#list1").editRow(id,true); lastSel = id; } } }); });
("#list1").jqGrid({ url: ''/CMS/GetCustomerData/5001'', datatype: ''json'', mtype: ''GET'', height: ''150'', rownumbers: true, colNames: [''id'', ''name'', ''company''], colModel: [ { name: ''id'', index: ''id'', editable: false, sortable: true, width: 20, align: ''left'' }, { name: ''name'', index: ''name'', editable: true, edittype: ''text'', sortable: true, search: true, width: 50, align: ''left'' }, { name: ''company'', index: ''company'', editable: true, edittype: ''text'', sortable: true, search: true, width: 50, align: ''left'' }], pager: jQuery(''#pager''), viewrecords: false, imgpath: ''/Content/Default/UIComponents/css/redmond/images'', caption: "Customer details", width: 900, hidegrid: false, multiselect: false, altRows: true, altclass: ''altRow'', onSelectRow: function(id) { if (id && id !== lastSel) { jQuery("#list1").saveRow(lastSel, true, ''clientArray''); jQuery("#list1").editRow(id, true); lastSel = id; } } }); });


嗨...

即时通讯给您一个例子..希望这对您有帮助..


在yuo shud这样的观点中写

hi...

im givin you one example..hope this may help you..


in the view yuo shud write like this


(文档).ready(function(){
var updateDialog = {
网址:''/Home/Update/''
,closeAfterAdd:true
,closeAfterEdit:true
,afterclickPgButtons:函数(whichbutton,formid和rowid){

}
,modal:true

,onclickSubmit:函数(参数){
var ajaxData = {};

var list =
(document).ready(function () {
var updateDialog = {
url: ''/Home/Update/''
, closeAfterAdd: true
, closeAfter true
, afterclickPgButtons: function (whichbutton, formid, rowid) {

}
, modal: true

, onclickSubmit: function (params) {
var ajaxData = {};

var list =


这篇关于如何从jqgrid向控制器发送数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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