在jqGrid的的编辑网址表单编辑传递参数 [英] Pass parameters in Edit Url of jqGrid for Form Editing

查看:1323
本文介绍了在jqGrid的的编辑网址表单编辑传递参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 jgGrid 表格编辑中,我更新了编辑的值。当我点击提交 editurl 被调用。在我的情况下这种情况下,我有两个参数传递给控制器​​。

// jqGrid的code:

  VAR colname需要= [];
    变种colHeader = [];
    VAR的GridData;


VAR了selectedValue;
VAR multipleSource;
变种colValues​​ = [];
VAR列= {[名称:工作流程名称,宽度:'为200px},{名称:工作流程分类',宽度:'150像素'},{名称:状态,宽度:'100px的'},{名:工作流程所有者',宽度:'150像素'}]。

$阿贾克斯({
            网址:@ Url.Action(LoadColumns,家),
           // URL:/首页/ LoadColumns
            数据:{workflowId:selectedValue,则状态:$('#状态选项:选择)VAL(),customView:$('#CustomViews选项:选择)VAL()},
            数据类型:JSON,
            键入:GET,
            成功:的onComplete,
            错误:OnFail
        });
        功能的onComplete(结果){
          //调试;
            的GridData = $ .parseJSON(结果)
            colHeader = [];
            colname需要= [];
            $每个(gridData.Table1,函数(){

            colHeader.push(this.Name);

            开关(this.Datatype){

                案INT:
                    colname.push({名this.Name,索引:this.Name,宽度:130,对齐:'左',可排序的:真正的,可编辑的:假的,sorttype:'诠释'});
                    打破;
                案串:
                    colname.push({名this.Name,索引:this.Name,宽度:130,对齐:'左',可排序的:真正的,可编辑:真正的});
                    打破;
                案日期时间:
                    colname.push({
                        名称:this.Name,搜索:真的,指数:this.Name,宽度:130,STYPE:文本,可编辑:真正的,searchoptions:{

                            dataInit:功能(EL){

                                $(EL).datepicker({
                                    DATEFORMAT:'M / D / Y',的maxDate:0,changeMonth:真,changeYear:真,调用onSelect:功能(dateText,研究所){
                                        的setTimeout(函数(){
                                            $('#jQGridDemo')[0] .triggerToolbar();
                                        },50);
                                    }
                                });

                            }
                        },editoptions:{
                            dataInit:功能(EL){

                                $(EL).datepicker({
                                    DATEFORMAT:'M / D / Y',的maxDate:0,changeMonth:真,changeYear:真
                                });

                            }
                        }
                    });
                    打破;
                案下拉菜单:

                    colname.push({

                        名称:this.Name,索引:this.Name,宽度:130,edittype:选择,格式:'选择',
                        cellattr:功能(ROWID,缬氨酸,rawObject,厘米,RDATA){
                            变种strVal = [];
                            strVal = val.split(_);

                            如果(rawObject [cm.name +_title] ==){
                              //调试;
                                回归的标题=+ strVal [0]的ToString()+'';
                            }
                            其他
                                回归的标题=+ VAL +'('+ rawObject [cm.name +_title] +')';

                        },
                        editoptions:{值:':选择; + this.ValueList.slice(0,-1)},STYPE:选择
                                ,searchoptions:{值:':所有; + this.ValueList.slice(0,-1)},对齐:'左',可排序的:真正的,可编辑:真正的
                    });
                    打破;
                默认:
                    colname.push({名this.Name,索引:this.Name,宽度:130,对齐:'左',可排序的:真正的,可编辑:真正的});
                    打破;
                    打破;
            }

        });

 jQuery的(#jQGridDemo)。jqGrid的({
            数据:gridData.BuildTransactionsDataTable,
            数据类型:本地,
            hoverrows:假的,
            colNames:colHeader,
            colModel:colname需要,
            ID:TRANSACTIONID,
            localReader:{
                根:行,
                ID:TRANSACTIONID,

                repeatitems:假的
            },
            的rowNum:10,
            rowList:[10,20,30],
            寻呼机:#jQGridDemoPager,
            sortname:_id,
            viewrecords:真正的,
            loadonce:真正的,
            排序顺序:递减,
            图片说明:网格,
            gridview的:真正的,
            AUTOEN code:真的,
            IGNORECASE:真

        });

jQuery的(#jQGridDemo)jqGrid的('filterToolbar',{stringResult:真,searchOperators:真,searchOnEnter:假的,defaultSearch:CN});


        $('#jQGridDemo')。jqGrid的('navGrid','#jQGridDemoPager',
                   {
                       编辑:真正的,
                       地址:真正的,
                       德尔:假的,
                       搜索:真实,
                       sea​​rchtext:搜索,
                       addtext:添加,
                       EditText上:编辑,
                       deltext:删除
                   },
                    {multipleSearch:真},
                     // {

                     {   //编辑
                         //高度:300,
                         //宽度:400,
                         //前:50,
                         //左:100,
                         // dataheight:280,
                         closeOnEscape:真正的,//关闭在pressing Esc键弹出
                         reloadAfterSubmit:真正的,
                         阻力:真正的,

                         afterSubmit:功能(响应,POSTDATA){
                             调试器;
                             如果(response.responseText ==){

                                 $(本).jqGrid('setGridParam',{数据类型:'json的'})触发('reloadGrid')。 //重新载入修改后的网格
                                 返回[真,'']
                             }
                             其他 {

                                 $(本).jqGrid('setGridParam',{数据类型:'json的'})触发('reloadGrid')。 //重新载入修改后的网格
                                 返回[虚假,response.responseText] //捕获和显示上个编辑窗口中的响应文本
                             }
                         },

                         onclickSubmit:功能(响应,POSTDATA){
                             调试器;
                             VAR resultGriddata = JSON.stringify(POSTDATA);
                             VAR resultColumndata = JSON.stringify(gridData.Table1);
                             $阿贾克斯({
                                 网址:/首页/的UpdateData
                                 数据类型:JSON,
                                 数据:{的GridData:resultGriddata,columnData:resultColumndata},
                                 键入:POST,
                                 成功:的onComplete,
                                 错误:OnFail
                             });
                             功能的onComplete(结果){
                                 警报(结果);
                             }
                         },
                         editData:{
                             TRANSACTIONID:函数(){

                                 变种sel_id = $('#jQGridDemo')jqGrid的('getGridParam','selrow')。
                                 VAR值= $('#jQGridDemo)jqGrid的('getCell',sel_id,'_id')。
                                 返回值;

                             }
                         }


                     },
               {
                   closeAfterAdd:真正的,//关闭添加窗口后添加
                   afterSubmit:功能(响应,POSTDATA){
                       调试器;
                       如果(response.responseText ==){

                           $(本).jqGrid('setGridParam',{数据类型:'json的'})。触发(reloadGrid)后加//重新加载网格
                           返回[真,'']
                       }
                       其他 {
                           警报(响应);
                           $(本).jqGrid('setGridParam',{数据类型:'json的'})。触发(reloadGrid)后加//重新加载网格
                           返回[虚假,response.responseText]
                       }
                   }
               },
               {   //删除
                   closeOnEscape:真正的,
                   closeAfterDelete:真正的,
                   reloadAfterSubmit:真正的,
                   closeOnEscape:真正的,
                   阻力:真正的,
                   afterSubmit:功能(响应,POSTDATA){
                       如果(response.responseText ==){

                           $(#jQGridDemo)触发(reloadGrid,[{电流:真}]);
                           返回[虚假,response.responseText]
                       }
                       其他 {
                           $(本).jqGrid('setGridParam',{数据类型:'json的'})触发('reloadGrid')。
                           返回[真,response.responseText]
                       }
                   },
                   delData:{
                       TRANSACTIONID:函数(){
                           变种sel_id = $('#jQGridDemo')jqGrid的('getGridParam','selrow')。
                           VAR值= $('#jQGridDemo)jqGrid的('getCell',sel_id,'_id')。
                           返回值;
                       }
                   }
               },
               {//搜索
                   closeOnEscape:真

               }
        );
  }
 

在此code我已经过了三个参数,这使得加载格:

//控制器code:

  [HttpPost]
        公众的ActionResult的UpdateData(字符串的GridData,串columnData)
        {

            返回内容(成功);

        }
 

我已经尝试过在两个方面:

1。添加EditData:                          我曾尝试加入 editData 下面的 editurl ,并试图传递一个参数。但我得到了空,结果在控制器中。

  editData:{_dokdata:函数(){返回JSON.stringify(的GridData); }}
 

2。传入onclickSubmit数据:                              我曾尝试发布的数据,在 onclickSubmit 事件控制器。像,

  onclickSubmit:功能(响应,POSTDATA){

                             postdata.extraParam =的GridData;
                             VAR resultGriddata = JSON.stringify(POSTDATA);
                             VAR resultColumndata = JSON.stringify(gridData.Table1);
                             $阿贾克斯({
                                 网址:/首页/的UpdateData
                                 数据类型:JSON,
                                 数据:{的GridData:resultGriddata,columnData:resultColumndata},
                                 键入:POST,
                                 成功:的onComplete,
                                 错误:OnFail
                             });
                             功能的onComplete(结果){
                                 警报(结果);
                             }
                         },
 

现在在 onclickSubmit 我要通过这两个参数,并得到这些值到控制器。眼下控制器获取调用有两个参数与预期值(数据)。我不知道在code中的其他活动。

但后面我在编辑弹出句话说得到错误后的过程中codeURL未设置。所以,我想在很多方面出现了像clientarray editurl cellsubmit ,但没有任何帮助。

有人说,在我的搜索,都应该是 InlineEdit 给予而不是 FormEdit 。不知道我是在那里我错了。

我怎样才能使这项工作不显示在弹出的错误?

SAMPLEDATA:

  {表1:[{姓名:从查询,数据类型:字符串,ValueList:,ValueId:139646 值类型:F},{姓名:分配给KARTHIK,数据类型:字符串,ValueList:,ValueId:139665,值类型:F },{姓名:现场Format","Datatype":"DateTime","ValueList":"","ValueId":"141803","ValueType":"F"},{"Name":"URLFields","Datatype":"String","ValueList":"","ValueId":"447592","ValueType":"F"},{"Name":"Testing","Datatype":"String","ValueList":"","ValueId":"705958","ValueType":"F"},{"Name":"Start任务,数据类型:下拉列表中,ValueList:在流程:在流程;完成:完成;重新工作所需:重新工作所需;分配:分配;不要求:不要求;,ValueId :139584,值类型:T},{姓名:创建凭证,数据类型:下拉列表中,ValueList:在流程:在流程;完成:完成;重工作要求:重新工作所需;分配:分配;不要求:不要求;,ValueId:139585,值类型:T},{姓名:分支和映射,数据类型:下拉列表中,ValueList:在流程:在流程;完成:完成;重新工作所需:重新工作所需;分配:分配;不要求:不要求;,ValueId:139586 值类型:T},{姓名:应用程序演练,数据类型:下拉列表中,ValueList:在流程:在流程;完成:完成;重新工作要求:重所需的工作;分配:分配;不要求:不要求;,ValueId:139587,值类型:T},{姓名:呼叫,数据类型:下拉列表中, ValueList:在流程:在流程;完成:完成;重新工作所需:重新工作所需;分配:分配;不要求:无Required;","ValueId":"139588","ValueType":"T"},{"Name":"Queries","Datatype":"dropdown","ValueList":"In过程:在流程;完成:完成;重新工作所需:重新工作所需;分配:分配;不要求:不要求;,ValueId:139589,值类型:T},{名称:开发就绪,数据类型:下拉列表中,ValueList:在流程:在流程;完成:完成;重新工作所需:重新工作所需;分配:分配;不要求:无Required;","ValueId":"139591","ValueType":"T"},{"Name":"Assign","Datatype":"dropdown","ValueList":"In过程:在流程;完成:完成;重新工作所需:重新工作所需;分配:分配;不要求:不要求;,ValueId:139666,值类型:T},{名称:检查开发,数据类型:下拉列表中,ValueList:在流程:在流程;完成:完成;重新工作所需:重新工作所需;分配:分配;不要求:无Required;","ValueId":"139701","ValueType":"T"}],"Table2":[{"TransactionId":"141090","TransactionStatus":"29607","StartDate":"1/18/1900下午5时02分00秒,从查询:Y,分配给KARTHIK:是的,字段格式:,URLFields:,测试:,开始任务:已完成,开始Task_Title:43_False,创建凭证:已完成,创建Credentials_Title:_假,分支和映射:已完成,分支和Mapping_Title :2_False,应用程序演练:空,应用Walkthrough_Title":null,"Call":"Completed","Call_Title":"_False","Queries":null,"Queries_Title":null,"Development准备就绪:空,发展Ready_Title:空,分配:空,Assign_Title:空,检查开发者:空,检查Developer_Title:空},{TRANSACTIONID:141101,的TransactionStatus :29607,起始日期:2013年5月10号上午12:00:00,从查询:N,分配给KARTHIK:是的,字段格式: URLFields:,测试:,启动任务:已完成,开始Task_Title:43_False,创建凭证:进行中,创建Credentials_Title:2_True ,分支和映射:已完成,分支和Mapping_Title:_假,应用程序演练:已完成,应用Walkthrough_Title":"_False","Call":"Completed","Call_Title":"_False","Queries":null,"Queries_Title":null,"Development准备就绪:空,发展Ready_Title:空,分配:空,Assign_Title:空,检查开发者:空,检查Developer_Title:空}]}
 

解决方案

首先,你应该决定使用哪种编辑模式。如果你想使用表单编辑则没有 cellEdit:真正的选项应该存在于你的code。呦使用了错误的选项 celledit 而不是 cellEdit ,所以这将是只是忽略,但这种选项的存在使得code更难看了。顺便说一句 cellsubmit 选项,你在你的问题提(例如 cellsubmit:远程)的作品仅在细胞编辑这需要的用法 cellEdit:真正的

你贴不包含任何形式的编辑code中的code。无论您是使用目前还不清楚 navGrid 有一些选项,或者您格式:行动 formatoptions :{editformbutton:真} 或来电 editGridRow 方法直接...哪种方案,以及如何准确地使用表单编辑是从你的问题不清楚所以一有猜测你做了什么。

如果你决定使用表格编辑,然后

你应该把 editData 在正确的位置 editData 不jqGrid的选项(见的这里)。它的参数 editGridRow 方法(可选项/属性)(看到这里)。取决于您应该如何使用表格编辑将其放置在相应的位置。例如,如果您使用 navGrid 然后是3-D和它的4个参数(参见 prmEdit prmAdd )允许您指定转发到<$ C选项C> editGridRow $由 navGrid 如果用户点击编辑或添加导航栏的按钮。您张贴在问题使用正确的位置 editData ,但添加 editData 下面的 editurl (见你的问题的文字)是错误的方法。

您写的我要通过两个参数来控制(但你发布的UpdateData 动作控制器的code中的只有参数的GridData )。你不公布 colModel 这使得更难理解你(你所用过误解的名称的方式: colModel:colname需要,而 COLNAME 选项有另一种价值 colHeader ),但可能是一列 colModel 编辑:真正的属性。在这种情况下表单编辑的使用看来我真的不是最好的选择和使用的单元格编辑可以更简单。要使用它,你需要添加 cellsubmit:远程 cellEdit:真正的 cellurl: /首页/的UpdateData。在这种情况下jqGrid的将发送到服务器(以 cellurl )的 3 的参数(见的文档):

  • 与像名称属性值名称的编辑数据 colModel
  • 在名称ROWID ID 。我们可以使用 prmNames 选项​​改变 ID 名称。例如 prmNames:{ID:TRANSACTIONID} 将改变ROWID的名称 TRANSACTIONID
  • 固定字符串 OPER =修改。人们可以通过使用更改名称 prmNames 。例如 prmNames:{OPER:myOper,editoper:myedit在} 将改变 OPER =修改 myOper = myedit在

此外可以使用 beforeSubmitCell serializeCellData 自定义数据:

beforeSubmitCell:功能(ROWID,名称,价值,iRow,ICOL){     返回{的GridData:的GridData}; }, serializeCellData:功能(POSTDATA){     返回JSON.stringify(POSTDATA); }

您可以在您需要的任何其他方式修改 serializeCellData 。例如

  serializeCellData:功能(POSTDATA){
    返回 {
        的GridData:JSON.stringify(postdata.gridData)
        columnData:JSON.stringify(postdata.columnNameFromColModel)
    };
}
 

I am using jgGrid form editing in which I am updating the edited values. When I click submit the editurl gets called. In that case in my scenario I have to pass two parameters to Controller.

//jqGrid Code:

    var colname = [];
    var colHeader = [];
    var gridData;


var selectedValue;
var multipleSource;
var colValues = [];
var columns = [{ name: 'Workflow Name', width: '200px' }, { name: 'Workflow Category', width: '150px' }, { name: 'Status', width: '100px' }, { name: 'Workflow Owner', width: '150px' }];

$.ajax({
            url: '@Url.Action("LoadColumns","Home")',
           // url: "/Home/LoadColumns",
            data: { 'workflowId': selectedValue, 'status': $('#Status option:selected').val(), 'customView': $('#CustomViews option:selected').val() },
            datatype: 'json',
            type: 'GET',
            success: OnComplete,
            error: OnFail
        });
        function OnComplete(result) {
          //  debugger;
            gridData = $.parseJSON(result)
            colHeader = [];
            colname = [];
            $.each(gridData.Table1, function () {

            colHeader.push(this.Name);

            switch (this.Datatype) {

                case 'int':
                    colname.push({ name: this.Name, index: this.Name, width: 130, align: 'left', sortable: true, editable: false, sorttype: 'int' });
                    break;
                case 'String':
                    colname.push({ name: this.Name, index: this.Name, width: 130, align: 'left', sortable: true, editable: true });
                    break;
                case 'DateTime':
                    colname.push({
                        name: this.Name, search: true, index: this.Name, width: 130, stype: "text", editable: true, searchoptions: {

                            dataInit: function (el) {

                                $(el).datepicker({
                                    dateFormat: 'm/d/y', maxDate: 0, changeMonth: true, changeYear: true, onSelect: function (dateText, inst) {
                                        setTimeout(function () {
                                            $('#jQGridDemo')[0].triggerToolbar();
                                        }, 50);
                                    }
                                });

                            }
                        }, editoptions: {
                            dataInit: function (el) {

                                $(el).datepicker({
                                    dateFormat: 'm/d/y', maxDate: 0, changeMonth: true, changeYear: true
                                });

                            }
                        }
                    });
                    break;
                case 'dropdown':

                    colname.push({

                        name: this.Name, index: this.Name, width: 130, edittype: "select", formatter: 'select',
                        cellattr: function (rowId, val, rawObject, cm, rdata) {
                            var strVal = [];
                            strVal = val.split("_");

                            if (rawObject[cm.name + "_Title"] == "") {
                              //  debugger;
                                return 'title="' + strVal[0].toString() + '"';
                            }
                            else
                                return 'title="' + val + ' (' + rawObject[cm.name + "_Title"] + ')"';

                        },
                        editoptions: { value: ':Select;' + this.ValueList.slice(0, -1) }, stype: 'select'
                                , searchoptions: { value: ':All;' + this.ValueList.slice(0, -1) }, align: 'left', sortable: true, editable: true
                    });
                    break;
                default:
                    colname.push({ name: this.Name, index: this.Name, width: 130, align: 'left', sortable: true, editable: true });
                    break;
                    break;
            }

        });

 jQuery("#jQGridDemo").jqGrid({
            data: gridData.BuildTransactionsDataTable,
            datatype: "local",
            hoverrows: false,
            colNames: colHeader,
            colModel: colname,
            id: 'TransactionId',
            localReader: {
                root: 'rows',
                id: 'TransactionId',

                repeatitems: false
            },
            rowNum: 10,
            rowList: [10, 20, 30],
            pager: '#jQGridDemoPager',
            sortname: '_id',
            viewrecords: true,
            loadonce: true,
            sortorder: 'desc',
            caption: "Grid",
            gridview: true,
            autoencode: true,
            ignoreCase: true

        });

jQuery("#jQGridDemo").jqGrid('filterToolbar', { stringResult: true, searchOperators: true, searchOnEnter: false, defaultSearch: "cn" });


        $('#jQGridDemo').jqGrid('navGrid', '#jQGridDemoPager',
                   {
                       edit: true,
                       add: true,
                       del: false,
                       search: true,
                       searchtext: "Search",
                       addtext: "Add",
                       edittext: "Edit",
                       deltext: "Delete"
                   },
                    { multipleSearch: true },
                     //{

                     {   //EDIT
                         //                       height: 300,
                         //                       width: 400,
                         //                       top: 50,
                         //                       left: 100,
                         //                       dataheight: 280,
                         closeOnEscape: true, //Closes the popup on pressing escape key
                         reloadAfterSubmit: true,
                         drag: true,

                         afterSubmit: function (response, postdata) {
                             debugger;
                             if (response.responseText == "") {

                                 $(this).jqGrid('setGridParam', { datatype: 'json' }).trigger('reloadGrid'); //Reloads the grid after edit
                                 return [true, '']
                             }
                             else {

                                 $(this).jqGrid('setGridParam', { datatype: 'json' }).trigger('reloadGrid'); //Reloads the grid after edit
                                 return [false, response.responseText]//Captures and displays the response text on th Edit window
                             }
                         },

                         onclickSubmit: function (response, postdata) {
                             debugger;
                             var resultGriddata = JSON.stringify(postdata);
                             var resultColumndata = JSON.stringify(gridData.Table1);
                             $.ajax({
                                 url: "/Home/UpdateData",
                                 datatype: 'json',
                                 data: { 'gridData': resultGriddata, 'columnData': resultColumndata },
                                 type: 'POST',
                                 success: OnComplete,
                                 error: OnFail
                             });
                             function OnComplete(result) {
                                 alert(result);
                             }
                         },
                         editData: {
                             TransactionId: function () {

                                 var sel_id = $('#jQGridDemo').jqGrid('getGridParam', 'selrow');
                                 var value = $('#jQGridDemo').jqGrid('getCell', sel_id, '_id');
                                 return value;

                             }
                         }


                     },
               {
                   closeAfterAdd: true, //Closes the add window after add
                   afterSubmit: function (response, postdata) {
                       debugger;
                       if (response.responseText == "") {

                           $(this).jqGrid('setGridParam', { datatype: 'json' }).trigger('reloadGrid')//Reloads the grid after Add
                           return [true, '']
                       }
                       else {
                           alert(response);
                           $(this).jqGrid('setGridParam', { datatype: 'json' }).trigger('reloadGrid')//Reloads the grid after Add
                           return [false, response.responseText]
                       }
                   }
               },
               {   //DELETE
                   closeOnEscape: true,
                   closeAfterDelete: true,
                   reloadAfterSubmit: true,
                   closeOnEscape: true,
                   drag: true,
                   afterSubmit: function (response, postdata) {
                       if (response.responseText == "") {

                           $("#jQGridDemo").trigger("reloadGrid", [{ current: true }]);
                           return [false, response.responseText]
                       }
                       else {
                           $(this).jqGrid('setGridParam', { datatype: 'json' }).trigger('reloadGrid');
                           return [true, response.responseText]
                       }
                   },
                   delData: {
                       TransactionId: function () {
                           var sel_id = $('#jQGridDemo').jqGrid('getGridParam', 'selrow');
                           var value = $('#jQGridDemo').jqGrid('getCell', sel_id, '_id');
                           return value;
                       }
                   }
               },
               {//SEARCH
                   closeOnEscape: true

               }
        );
  }

In this code I have passed three parameters which makes the grid loaded:

//Controller Code:

 [HttpPost]
        public ActionResult UpdateData(string gridData, string columnData)
        {

            return Content("Success");

        }

I have tried it in two ways:

1. Adding EditData: I have tried adding the editData below the editurl and tried passing a single parameter. But i got null as a result in the Controller.

 editData: { _dokdata: function () { return JSON.stringify(gridData); } }

2. Passing data in onclickSubmit: I have tried posting the data to controller in the onclickSubmit event. Like,

 onclickSubmit: function (response, postdata) {

                             postdata.extraParam = gridData;
                             var resultGriddata = JSON.stringify(postdata);
                             var resultColumndata = JSON.stringify(gridData.Table1);
                             $.ajax({
                                 url: "/Home/UpdateData",
                                 datatype: 'json',
                                 data: { 'gridData': resultGriddata,     'columnData':resultColumndata },
                                 type: 'POST',
                                 success: OnComplete,
                                 error: OnFail
                             });
                             function OnComplete(result) {
                                 alert(result);
                             }
                         },

Now in the onclickSubmit I have to pass both parameters and get those values into the controller. Right now the controller is getting called with both parameters with values as expected(the data). I am not sure of the other events in the code.

But after the process in code behind I get error in the edit popup saying that "Url is not set". So I tried in many ways giving like 'clientarray' for editurl and cellsubmit, but nothing helped.

It was said that in my search, all should be given for InlineEdit and not for FormEdit. Not sure i'm where i'm wrong.

How can I make this work without showing the error in the popup?

SampleData:

{"Table1":[{"Name":"Have Queries","Datatype":"String","ValueList":"","ValueId":"139646","ValueType":"F"},{"Name":"Assign to Karthik","Datatype":"String","ValueList":"","ValueId":"139665","ValueType":"F"},{"Name":"Field Format","Datatype":"DateTime","ValueList":"","ValueId":"141803","ValueType":"F"},{"Name":"URLFields","Datatype":"String","ValueList":"","ValueId":"447592","ValueType":"F"},{"Name":"Testing","Datatype":"String","ValueList":"","ValueId":"705958","ValueType":"F"},{"Name":"Start Task","Datatype":"dropdown","ValueList":"In Process:In Process;Completed:Completed;Re-Work Required:Re-Work Required;Assigned:Assigned;Not Required:Not Required;","ValueId":"139584","ValueType":"T"},{"Name":"Create Credentials","Datatype":"dropdown","ValueList":"In Process:In Process;Completed:Completed;Re-Work Required:Re-Work Required;Assigned:Assigned;Not Required:Not Required;","ValueId":"139585","ValueType":"T"},{"Name":"Branching and Mapping","Datatype":"dropdown","ValueList":"In Process:In Process;Completed:Completed;Re-Work Required:Re-Work Required;Assigned:Assigned;Not Required:Not Required;","ValueId":"139586","ValueType":"T"},{"Name":"Application Walkthrough","Datatype":"dropdown","ValueList":"In Process:In Process;Completed:Completed;Re-Work Required:Re-Work Required;Assigned:Assigned;Not Required:Not Required;","ValueId":"139587","ValueType":"T"},{"Name":"Call","Datatype":"dropdown","ValueList":"In Process:In Process;Completed:Completed;Re-Work Required:Re-Work Required;Assigned:Assigned;Not Required:Not Required;","ValueId":"139588","ValueType":"T"},{"Name":"Queries","Datatype":"dropdown","ValueList":"In Process:In Process;Completed:Completed;Re-Work Required:Re-Work Required;Assigned:Assigned;Not Required:Not Required;","ValueId":"139589","ValueType":"T"},{"Name":"Development Ready","Datatype":"dropdown","ValueList":"In Process:In Process;Completed:Completed;Re-Work Required:Re-Work Required;Assigned:Assigned;Not Required:Not Required;","ValueId":"139591","ValueType":"T"},{"Name":"Assign","Datatype":"dropdown","ValueList":"In Process:In Process;Completed:Completed;Re-Work Required:Re-Work Required;Assigned:Assigned;Not Required:Not Required;","ValueId":"139666","ValueType":"T"},{"Name":"Check Developer","Datatype":"dropdown","ValueList":"In Process:In Process;Completed:Completed;Re-Work Required:Re-Work Required;Assigned:Assigned;Not Required:Not Required;","ValueId":"139701","ValueType":"T"}],"Table2":[{"TransactionId":"141090","TransactionStatus":"29607","StartDate":"1/18/1900 5:02:00 PM","Have Queries":"Y","Assign to Karthik":"Yes","Field Format":"","URLFields":"","Testing":"","Start Task":"Completed","Start Task_Title":"43_False","Create Credentials":"Completed","Create Credentials_Title":"_False","Branching and Mapping":"Completed","Branching and Mapping_Title":"2_False","Application Walkthrough":null,"Application Walkthrough_Title":null,"Call":"Completed","Call_Title":"_False","Queries":null,"Queries_Title":null,"Development Ready":null,"Development Ready_Title":null,"Assign":null,"Assign_Title":null,"Check Developer":null,"Check Developer_Title":null},{"TransactionId":"141101","TransactionStatus":"29607","StartDate":"5/10/2013 12:00:00 AM","Have Queries":"N","Assign to Karthik":"Yes","Field Format":"","URLFields":"","Testing":"","Start Task":"Completed","Start Task_Title":"43_False","Create Credentials":"In Process","Create Credentials_Title":"2_True","Branching and Mapping":"Completed","Branching and Mapping_Title":"_False","Application Walkthrough":"Completed","Application Walkthrough_Title":"_False","Call":"Completed","Call_Title":"_False","Queries":null,"Queries_Title":null,"Development Ready":null,"Development Ready_Title":null,"Assign":null,"Assign_Title":null,"Check Developer":null,"Check Developer_Title":null}]}

解决方案

First of all you should decide which editing mode you use. If you want to use form editing then no cellEdit: true option should exist in your code. Yo used wrong option celledit instead of cellEdit, so it will be just ignored, but the existence of such options makes the code more difficult to read. By the way cellsubmit option which you mention in your question (for example cellsubmit: "remote") works only in case of cell editing which required the usage of cellEdit: true.

The code which you posted don't contains any form editing code. It's unclear whether you use navGrid with some options or you formatter: "actions" with formatoptions: {editformbutton: true} or calls editGridRow method directly ... Which options and how exactly you use form editing is unclear from your question so one have to guess what you do.

If you decide to use form editing then you should place editData in correct place. editData is not jqGrid option (see here). It's parameter (option/property) of editGridRow method (see here). Depend on how you use form editing you should place it in the corresponding place. For example if you use navGrid then the 3-d and 4-th parameters of it (see prmEdit and prmAdd) allows you to specify the option forwarded to editGridRow by navGrid if the user click Edit or Add button of the navigator bar. The code which you posted in the question uses correct place for editData, but "adding the editData below the editurl" (see the text of your question) is the wrong way.

You wrote "i have to pass 2 parameters to Controller" (but the code of UpdateData action controller which you posted contains only one parameter gridData). You don't posted colModel which makes more difficult to understand you (by the way you used misunderstanding names: colModel: colname, but colName option have another value colHeader), but probably exactly one column from colModel have editable: true property. In the case the usage of form editing seems me really not the best choice and usage cell editing could be more simple. To use it you need add cellsubmit: "remote", cellEdit: true and cellurl: "/Home/UpdateData". In the case jqGrid will send to the server (to cellurl) 3 parameters (see the documentation):

  • The editing data with the name like the value of name property in colModel.
  • rowid under the name id. One can use prmNames option to change the id name. For example prmNames: {id: "TransactionId"} will change the name of rowid to TransactionId.
  • Fixed string oper=edit. One can change the names by usage prmNames. For example prmNames: {oper: "myOper", editoper: "myEdit"} will change oper=edit to myOper=myEdit.

Additionally one can use beforeSubmitCell and serializeCellData to customize the data:

beforeSubmitCell: function (rowid, name, value, iRow, iCol) {
    return {gridData: gridData};
},
serializeCellData: function (postdata) {
    return JSON.stringify(postdata);
}

You can change serializeCellData in any other way which you need. For example

serializeCellData: function (postdata) {
    return {
        gridData: JSON.stringify(postdata.gridData),
        columnData: JSON.stringify(postdata.columnNameFromColModel)
    };
}

这篇关于在jqGrid的的编辑网址表单编辑传递参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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