jqgrid保存记录以进行内联编辑 [英] jqgrid saving records for inline editing

查看:98
本文介绍了jqgrid保存记录以进行内联编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在jqgrid中,当我们单击保存图标时进行内联编辑,**内部调用了saveRow方法,但是我想调用我的自定义方法,在该方法中我将实现我的保存逻辑以及调用控制器方法.**

我将以下代码用于网格.

var grid = jQuery("#list5").jqGrid({
            url: '/home1/GetUserData',

                datatype: "json",
                mtype: "POST",
                colNames: ['Code', 'LoginID', 'Emailid', 'CreateDate', 'PostalCode', 'Mobile'],
                colModel: [
                            {name: 'Code', index: 'Code', width: '16%', editable: true, sortable: true },
                            { name: 'LoginID', index: 'LoginID', width: '16%', editable: true, sortable: true },
                            { name: 'Emailid', index: 'Emailid', width: '16%', editable: true, 

        sortable: true },
                              ],
                    rowNum: 10,
                    height: '100%',
                    scrollOffset: 0,
                    rowList: 10,
                    shrinkToFit: true,
                    pager: $("#pager2"),
                    editurl: "/home1/EditUserData",
                    caption: "Simple data manipulation"
                });
                jQuery("#list5").jqGrid('navGrid', '#pager2', { edit: false, add: false, del: true, search: false, refresh: false }, {}, {}, { url: '/home1/DeleteUserData' });
                jQuery('#list5').jqGrid('inlineNav', '#pager2', { edit: true, add: true},
                });
            });

所以请任何人让我知道如何实现它.

解决方案

我不太了解您的要求. saveRow 具有很多自定义可能性.您可以使用jqGrid的prmNames选项重命名将发送到服务器的所有参数.使用 saveRow extraparam参数,您可以指定其他可以发送到服务器的信息.回调serializeRowData可用于实现自定义序列化.例如,您可以将数据转换为JSON.使用aftersavefunc,您可以在数据成功保存到服务器上之后执行一些自定义操作.因此,我建议您使用这些功能,而不要实现自定义的saveRow方法.

已更新:如果要使用使用自定义saveRow的导航器图标,则不要通过 inlineNav .您可以使用 inlineNav save: false选项.然后,您可以使用 navButtonAdd 并添加外观如下的自定义图标完全类似于原始的保存"按钮,并在onClickButton回调中调用您的自定义saveRow".

in jqgrid for inline editing when we click the save icon, ** internally it calls the saveRow method, but i want to call my custom method where i will implement my save logic as well calling to controller method.**

i used below code for grid.

var grid = jQuery("#list5").jqGrid({
            url: '/home1/GetUserData',

                datatype: "json",
                mtype: "POST",
                colNames: ['Code', 'LoginID', 'Emailid', 'CreateDate', 'PostalCode', 'Mobile'],
                colModel: [
                            {name: 'Code', index: 'Code', width: '16%', editable: true, sortable: true },
                            { name: 'LoginID', index: 'LoginID', width: '16%', editable: true, sortable: true },
                            { name: 'Emailid', index: 'Emailid', width: '16%', editable: true, 

        sortable: true },
                              ],
                    rowNum: 10,
                    height: '100%',
                    scrollOffset: 0,
                    rowList: 10,
                    shrinkToFit: true,
                    pager: $("#pager2"),
                    editurl: "/home1/EditUserData",
                    caption: "Simple data manipulation"
                });
                jQuery("#list5").jqGrid('navGrid', '#pager2', { edit: false, add: false, del: true, search: false, refresh: false }, {}, {}, { url: '/home1/DeleteUserData' });
                jQuery('#list5').jqGrid('inlineNav', '#pager2', { edit: true, add: true},
                });
            });

so please anyone let me know how to implement it.

解决方案

I don't really understand your requirements. saveRow has a lot of customization possibilities. You can rename all parameters which will be sent to the server using prmNames option of jqGrid. Using extraparam parameter of saveRow you can specify additional information which can be sent to the server. The callback serializeRowData can be used to implement your custom serialization. For example you can convert the data to JSON. Using aftersavefunc you can make some custom actions after the data will be successfully saved on the server. So I recommend you use the features instead of implementing your custom saveRow method.

UPDATED: If you want to have navigator icon which uses your custom saveRow you should don't add "Save" button by inlineNav. You can use save: false option of inlineNav. Then you can just use navButtonAdd and add your custom icon which look exactly like original "Save" button and make call of your "custom saveRow" in the onClickButton callback.

这篇关于jqgrid保存记录以进行内联编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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