Enter text into row, hit enter and go to the next row, same column
Enter text into row, hit enter and go to the next row, same column
54696d20
Posts: 75Questions: 18Answers: 0
Hey. Wondering if you have something already built. I'm using something like https://datatables.net/examples/api/form.html. I have an onchange event that get's the data when changed and passes it to my DB. Instead of clicking on the next text box. I would like it to auto select the next row, same column input box
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I haven't tried it with your specific requirements but may the KeyTable extension will help.
Kevin
@kthorngren kind of. I'm not looking for the focus to be on the next column, but the next row, same column. Like someone hit the tab button. I'm also giving the option to either enter data or scan a barcode into that input.
Side note: I only have one column you can edit/add
TIm
To add to what I mentioned. I have an onchange event on that input box. So it's triggered on enter or scanned. So I'm researching a way to maybe trigger a keydown event (9).
Thanks for the clarification. I updated a previous example that might get you started:
http://live.datatables.net/naxemane/1/edit
The last two lines in the
change
event is what you would be interested in. It usescell().index()
to get the current row and column. It uses row + 1 andnode()
to get the next row'std
. Then it uses jQuery to focus theinput
element of the next row.A couple of caveats:
- Ordering is turned off using
order: []
. Ordering complicates getting the next row.- There is no checking for the last row in the table. You may want to see if
nextCell
is undefined to handle this situation.If this doesn't help maybe you can build a simple example so we can help with your specific solution config.
Kevin
@kthorngren I am using Order. http://live.datatables.net/yeqazuze/27
Your onchange function call is not found. Instead of troubleshooting that I updated my example to simply use jQuery to move the focus to the next row.
http://live.datatables.net/qosejica/1/edit
I get the column index using the same API as before but then use jQuery to focus the input of the same column in the next row. This seems to work with ordering. However if you order your
Barcode
column then the focus might not be the next row after ordering takes place. Might be confusing for the user.Kevin
Oh it's there. Didn't test on why it doesn't work. But with your example. I was able to come up with (this example looks for what table it came from)
http://live.datatables.net/yeqazuze/29
Thanks
Hi,
I tried the code with
http://live.datatables.net/naxemane/1/edit
It's works well on first 3 rows, but other rows dose not work.
ex. when I tried on row 4, it will jump to row 16.
May I know if any things I missed ?
thanks