1

I want to use inline editing with Esc and Enter keys and I'm using inlineNav method. I already set keys: true for editRow method and keys are working. While I'm usig "add row" button, keys are not forking for the first time. I must cancel this operation by mouse and when I tried to add row again, keys are working normally. I have no clue how to debug this. It's jqGrid v. 4.4.4

$("myGrid").jqGrid(finalConfig)
  .navGrid(gridToolbar).inlineNav(gridToolbar, {
     editParams: { keys: true }
  }
);
dmnc
  • 966
  • 1
  • 9
  • 19
  • my `finalConfig` varialble imho doesn't contain anything relevant to the problem but I may export it and edit my question if needed. – dmnc Mar 28 '13 at 14:14
  • Did you set the `keys: true` for the `addRowParams :` ? – Mark Mar 28 '13 at 14:25
  • @Mark, the `inlineNav` method supports just `addParams` object and `keys` option doesn't work here. I'm not configuring the `addRow` method directly even not `editRow`, just that inline navigator. And `addRow` method calls `editRow` itselfs. But it seems to be some kind of bug, it's not working just once, it's ok on second try... http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing – dmnc Mar 28 '13 at 14:35
  • I reviewed the documentation before answering and I focused on `addRowParams : (object) parameters which are passed to the addRow - they are the same as of editRow` – Mark Mar 28 '13 at 14:44
  • @Mark and indeed it was a good track to the solution, as is described by Oleg. Anyway thanks to you too. – dmnc Mar 28 '13 at 15:33

1 Answers1

2

If you want to define some common settings for inline editing I would recommend you to use $.jgrid.inlineEdit. For example

$.extend($.jgrid.inlineEdit, { keys: true });

In the case you will have Enter key working in any form of usage of inline editing. In the case inline editing activated per formatter: "actions" will works in the same way like Add and Edit buttons added by inlineNav.

Alternatively you have to specify special for inlineNav the option for "add row" button in the following way

$("#myGrid").jqGrid("inlineNav", "#pager", {
    editParams: { keys: true },
    addParams: { addRowParams: { keys: true } }
});

Typically one defines all inline editing options in one object and uses the same options object twice:

var editingOptions = { keys: true };

$("#myGrid").jqGrid("inlineNav", "#pager", {
    editParams: editingOptions,
    addParams: { addRowParams: editingOptions }
});

See the answer for more code examples.

UPDATED: I think I found the reason why you had keys: false used during Add operation at the beginning, but had later keys: false working. The reason is the bug which I described in the bug report which I just posted. You can try to use fixed version of jquery.jqGrid.src.js (you can get it here). The reason was that

  1. inlineNav has one bug: it uses always editParams inside of "Cancel" event handler (see the line) even if we cancel "Add" operation. So the method restoreRow was called with editParams as parameter.
  2. The next bug is that the line of restoreRow changes $.jgrid.inlineEdit instead of just usage it. To fix the bug one have to change the line
o = $.extend(true, $.jgrid.inlineEdit, o );

to

o = $.extend(true, {}, $.jgrid.inlineEdit, o);
Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Thank you! `addParams: { addRowParams: { keys: true } }` is a solution. But I can't still understand the first scenario, why nothing happend on first try (got no addRowParams) and working on second (using inherited editParams). I thought editRow method has been called prior to user input ... – dmnc Mar 28 '13 at 15:06
  • @pavian: You are welcome! What you mean under "first scenario"? Is the usage of `$.extend($.jgrid.inlineEdit, { keys: true });` not work? Do you placed the line *before* calling of `inlineNav`? If you don't use any `addParams.addRowParams` option then when Add calls `editRow` internally only default options of `editRow` will be used. If "Edit" button clicked `editRow` will be called with `editParams` options. – Oleg Mar 28 '13 at 15:18
  • I mean my own "scenario" ... why it works for the second try? – dmnc Mar 28 '13 at 15:58
  • @pavian: I don't understand you. Could you explain more clear what you want? In the code which you posted in the question you don't specify and option for "Add" button. You specify setting for "Edit" button only. So "Add" used default value `keys: false`. – Oleg Mar 28 '13 at 16:33
  • yes, I've just specified "Edit", I misunderstood the [documentation](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing&s[]=After%20this%20the%20method%20call%20editRow%20method) and thought "Add" settings will be inherited. Now I get it, but still don't know how it is possible that keys aren't working in first "Add" operation but next time, I mean after canceling edit and doing "Add" again, they're working (`keys: true` is set just in `editParams`). – dmnc Mar 28 '13 at 18:43
  • 1
    @pavian: Probably there are some additional bug in `inlineNav`, but you should provide the demo with exact description of the test case which reproduce it. Two day ago for example I posted 3 bugs in the method (see [here](http://www.trirand.com/blog/?page_id=393/bugs/)). I believe that there are many other bugs. Just clicking of Add button once and at the second time don't changes behavior of `key: false` at my demos. I suppose that the bug exist if one *combines* clicking on Add and Edit buttons (if you click Add *after* Edit button for example). – Oleg Mar 28 '13 at 19:41
  • @pavian: I think that I found the bug in inline editing. Look at "UPDATED" part of my answer. – Oleg Mar 29 '13 at 18:12
  • @pavian: You are welcome! Could you verify in your application that if you replace `jquery.jqGrid.src.js` (or `jquery.jqGrid.min.js`) to [this one](http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.4.4/js/jquery.jqGrid.src-restoreRow.js) that the problem with changing of `keys: false` to `keys: true` will be fixed? – Oleg Mar 30 '13 at 19:50
  • Yes, now it's ok, addRow's `keys` still remains "off" in this [fiddle](http://jsfiddle.net/dmnc_net/AH2bG/2) while [/1 version](http://jsfiddle.net/dmnc_net/AH2bG/1) uses original source and keys becomes true on second time (which is wrong and original reason of my question)... – dmnc Mar 30 '13 at 20:13
  • yw and I thank you. I'm glad that my question had a good purpose. – dmnc Mar 30 '13 at 20:36