Change Tab behavior
Change Tab behavior
I've set up a DT + Keytable instance and its working great.
We are going to use a barcode scanner to input data into the application, and it sends TAB on successful scans (I think can make it send CR as well).
TAB moves the focus to the next column to the right. Can it be configured to stay in the same column, but drop to the next row similar to what we can do in Excel? Basically, I need to scan the serial numbers of a bunch of items, and each one be on a new row.
This question has an accepted answers - jump to answer
yes, you would just a keydown event handler that watches for the tab key. When seen, set focus where you need it
if you know the number of rows you have in advance, you can set the tabindex based on this calculation:
var g = (totalRows * column + row ) + 1 (plus one cause you cannot start with zero)
here is an example:
Yes, KeyTable's tab behaviour is to move to the left (or right), which I think is what Excel does is it not?
That line could be modified to be
downif you wanted to change the current behaviour.
@bindrid Gotcha. I'm a newbie of sorts with the JS but I looked at your code and somewhat understand.
I won't know the number of rows in advance so that might not work for me.
This is what I am currently using:
Basically I will have a table filled with requests for various systems. I will use the search feature in DT to make the table only show, say, PC Desktops. I have a stack of PC Desktop boxes with barcodes on them for serialnum and umpid.
I'd like to place the cursor in the first row, and the column I want, then scan that barcode and have it drop to the same column on the next row. Basically I am just assigning a particular scanned barcode to a particular user.
@allan Is that in the keytable code where you mentioned I could change the functionality to
down? I am using a DT setup that is built on the site using the CDN and that may make it more difficult to edit the soruce code. Is there some configuration option I could use in my code to accomplish the same? I couldn't locate anything in the docs, but easily could have missed it. Open to any ideas.
Thanks so much for the help, guys.
Yes - rather than
'left'if you use
'down'KeyTable will sort out the focus for you. In this case there isn't an option for what you are looking for - but its not an unreasonable one I think! That's something I'd be willing to add in.
How do you make Excel behave like that? I'd basically like KeyTables' behaviour to be similar to Excels.
@allan Thanks so much for the clarification! I think what we have done rather is modified the scanner configuration so that it sends a CR instead of tab. That drops it down a row vs. moving to the next column to the right.
What I see with things set up like they are now (scanner sending CR after), is that in DT it enters the data in the field and just stays focused there.
Maybe in my case I could make the scanner send a "down arrow" instead. It's a thought.