简体   繁体   English

jQgrid:在编辑网格行时禁用内联保存和Esc处理程序?

[英]jQgrid : Disable inline Save and Esc Handler while editing grid Row?

I am developing a asp.net MVC 4 project which uses jQgrid for generating table data.In my generated grid i am providing an inline edit option for particular columns in a row. 我正在开发一个使用jQgrid生成表数据的asp.net MVC 4项目。在生成的网格中,我为行中的特定列提供了内联编辑选项。

My problem is like while editing a particular row if i press Enter or Esc key my selected row is going out of edit mode. 我的问题就像在编辑特定行时,如果按EnterEsc键,我选择的行将退出编辑模式。

I want to disable those events Enter and Esc . 我想禁用这些事件Enter和Esc。

I googled about this problem and i get some interesting posts How to disable Save Handler on Jqgrid while doing editing 用谷歌搜索了这个问题,并得到了一些有趣的帖子如何在编辑时在Jqgrid上禁用Save Handler

Here in the above reference post i can see that some of the lines are commented out from Jqgrid.src.js file which i dont think as a best solution. 在上面的参考文章中,我可以看到Jqgrid.src.js文件中的某些行被注释掉了,我认为这不是最好的解决方案。

Is there any other method so that i can disable both Enter and Esc Event in Jqgrid while doing inline editing. 还有其他方法可以让我在进行内联编辑时同时禁用Jqgrid中的EnterEsc Event。

Javascript COde Javascript代码

jQuery("#Grid").jqGrid({
        url: baseUrl + '/api/Controller/method',
        datatype: "json",
        mtype: "POST",
        colNames: ['Col1', 'Col2', 'Col3', 'Col4', 'Col5'],
        colModel: [
        { name: 'col1', index: 'col1', align: 'center', editable: true, key:true },
        { name: 'col2', index: 'col2', align: 'center' },
        { name: 'col3', index: 'col3', align: 'center', editable: true, key:true },
        { name: 'col4', index: 'col4', align: 'center' },
        { name: 'col5', index: 'col5', align: 'center', editable: true, key:true }
        ],
        jsonReader: {
            root: 'data',
            id: 'col2',
            repeatitems: false
        },
        pager: $('#Pager'),
        rowNum: 10,
        rowList: [10, 25, 50, 100],
        autowidth: true,
        shrinkToFit: false,
        viewrecords: true,
        loadonce: true,
        autoencode: true,
        multiselect: true,
        height: '100%',
        width: '100%',
        caption: "Record"

        });

Sample Grid Structure 样本网格结构

样例网格图像

Note: Grid Image shown is not the actual grid generated with the above code. 注意:显示的网格图像不是使用以上代码生成的实际网格。

Here in the above grid there are some columns are left editable.My scenario is like i want to put data in all editable column in each row , so that i can update the grid data to server by a button click placed below the grid(Button not shown in the above image).Here i am not using editUrl property of grid. 在上面的网格中,有些列是可编辑的。我的情况就像我想将数据放在每一行的所有可编辑列中,这样我就可以通过单击网格下方的按钮来将网格数据更新到服务器(Button上图中未显示)。这里我没有使用grid的editUrl属性。

Currently if i edit first row and accidently if i press enter or Esc key the selected row will become non editable.I want to keep all editable cells in a row as editable untill i press the Submit button placed below the Grid. 目前,如果我编辑第一行,并且如果不小心按下Enter键或Esc键,则所选行将变为不可编辑状态。我想将一行中的所有可编辑单元格保持可编辑状态,直到我按下位于网格下方的Submit按钮。

My jQgrid Version is 4.5.4 我的jQgrid版本是4.5.4

Any help is appreciated. 任何帮助表示赞赏。

It's difficult to answer on the question which don't contains neither JavaScript code nor exact references on jqGrid version which you use. 对于不包含JavaScript代码或使用的jqGrid版本没有确切引用的问题,很难回答。 You don't describe in which form you use inline editing in the grid. 您没有描述在网格中使用哪种形式的内联编辑。

The usage of Esc and Enter during inline editing can be managed by keys: true option. 内联编辑期间, EscEnter的用法可以通过以下keys: true进行管理keys: true选项。 The exact syntax of the usage of keys option depend on how you use inline editing. 使用keys选项的确切语法取决于您如何使用内联编辑。 For example you can call editRow directly or use some other methods mile inlineNav or the formatter: "actions" which calls editRow for you. 例如,您可以直接调用editRow或使用其他方法mile inlineNav格式化程序:“ actions”为您调用editRow The default value of keys option is already false , so you change the value somewhere in your code to true . keys选项的默认值已经为false ,因此您可以将代码中的某个位置的值更改为true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM