How to disable Save Handler on Jqgrid while doing editing

穿精又带淫゛_ 提交于 2019-12-02 20:04:44

问题


I am working on an ASP.net MVC 4.0 application with Jqgrid.

I am making all rows as editable with some columns being editable and some non editable.

The Problem here is , i dont want to use Save and ESC handlers.

I am saving row details on the blur event of one of the text boxes. and still i need to stay in EDIT Mode.

So, if the user mistakenly presses enter , the row is going out of edit mode.

How to disable these Esc and Save Handlers

Please help..

Updated:

I am not using either cell edit or inline editing or form editing.

I am converting all rows as editable on the loadComplete trigger of the Jqgrid

i have only one Column being editable. that is of type Textbox

So, on the blur event of it , i am saving that to database using an ajax post .

Every thing is working fine upto this.

Here, the grid needs to be in edit mode even after saving value to database.

But, when clciking on enter on that row, it is moving out of edit mode which violates my requirement

I need to stop row moving to View mode from edit mode when ESC or Enter Keys are pressed

I hope this is clear..if not i will mention more..


回答1:


I Solved it in this way:

Dont know whether it is right way of doing this:

Oleg..i need your views on this:

    if(cnt > 0) {
        svr.id = rowid; $t.p.savedRow.push(svr);
        $(ind).attr("editable","1");
        $("td:eq("+focus+") input",ind).focus();
        if(o.keys===true) {
            $(ind).bind("keydown",function(e) {
                if (e.keyCode === 27) {
//                  debugger
//                  $($t).jqGrid("restoreRow",rowid, o.afterrestorefunc);
//                  if($t.p._inlinenav) {
//                     try {
//                        $($t).jqGrid('showAddEditButtons');
//                     } 
//                     catch (eer1) {}
//                  }
                    return false;
                }
                if (e.keyCode === 13) {
//                  var ta = e.target;
//                  if(ta.tagName === 'TEXTAREA') { return true; }
//                  if( $($t).jqGrid("saveRow", rowid, o ) ) {
//                      if($t.p._inlinenav) {
//                          try {
//                              $($t).jqGrid('showAddEditButtons');
//                          } catch (eer2) {}
//                      }
//                  }
                    return false;
                }
            });
        }
        $($t).triggerHandler("jqGridInlineEditRow", [rowid, o]);
        if( $.isFunction(o.oneditfunc)) { o.oneditfunc.call($t, rowid); }
    }

This is the code , i found in the Jqgrid.src.js

Since, i done need restoreRow and saveRow to be called when Enter key or ESC is pressed, i commented out the code .

I dont know if it is right way to do it. but, this worked indeed for my Scenario.



来源:https://stackoverflow.com/questions/20786045/how-to-disable-save-handler-on-jqgrid-while-doing-editing

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!