one question for all advanced in jqgrid.
i have to code this usecase:
In jqGrid there are two editable columns. I have to use cell editing. User click to one editable cell and when he presses 'Enter' key, i select next editable cell UNDER actual one.
Otherwise, when he hits 'tab' key, i select next editable cell
- if actual cell is last, i set the nearest editable cell in the next line or
- if not, i select next editable cell in the actual row.
to sum up – i need exact behaviour like in excel.
if i had better reputation, I could have uploaded an image to demonstrate desired situation.
thanks a lot.
I realize this is an old topic, but I recently wrestled with this and thought I would share the approach that worked for me:
I came up with this approach after reading how jqGrid's editCell function deals with tab and enter keys during an edit operation. jqGrid's keydown binding should fire first, followed by this one. This code simply tells it to start an edit in the next row after jqGrid's ENTER handler is processed. It works exactly like tab does now, keeping the edit control open.
I was never able to fully decipher the editoptions: { dataEvents:... } structure, so that might be a better approach. If so, feel free to explain how it is superior.
your answer helps me a lot and directs me to right solution, although i spent longer than 3 hours to write right code, but i managed this :)
thanks a lot.
to sum up:
i defined 2 variables:
i set them in beforeEditCell events:
and then in editoptions for both editable cells i set:
first editable cell in row (Inventúrny stav in the picture), behaviour on press tab to select next editable cell is default
second editable cell in row (Sklad. cena in the picture) - i manually set iCol for next editable cell in the next row
Ahoj!
To bind editable cell to your custom event handler there are common setting in jqGrid:
dataEvents
property of editoptions. Absolutely the same settings exist for the searching in jqGrid. You can find some code examples here, here and here. You will probably needed to use cell editing methods inside of the keyboard event handler to be able to end editing of one cell and to start editing of another one.If you will have problem in the implementation you can append your question with the code example and then one can try to modify it.