Friday, August 31, 2007

Easy scrolling in a table

If you have a backgound in Oracle Forms, you'll really like this post, because you are used to these functions: "key-up, key-down, current-record-visual-attribute", and so on........Especially the arrow keys to scroll a table !

It is possible to implement this in an ADF application. It takes some time to figure out, but it works, at least I'm very close now.

Using some of the logic from one of my previous posts I managed to implement "easy scrolling".

It take some javascript;
0: make the row current after click. "makeCurrent()".
1: find out the key pressed "checkKey()".
2: do the up or down action "nextRow()" and "previousRow()".
3: make sure you don't loose focus "holdCurrentField()".

You'll have to add onclick="makeCurrent()" and onkeydown="checkKey()" to every column in you're table. This will cause the row become current when clicked on it and the onkeydown will implement the scrolling with the arrow keys.

At the moment onkeydown="checkKey(this,event,#{bindings.Employees1.rangeStart},#{bindings.Employees1.rangeSize});" , I'm not sure if I really need the range values in this solution, but I have something that I'm working on to make this solution more sophisticated.

The "current row" is highlighted by evaluating the rowKey of the row and the rowkey of the iterator: styleClass="#{row.rowKeyStr == bindings.Employees1Iterator.currentRowKeyString ? 'highligthSelectedRow' : ''}"
where 'highligthSelectedRow' is an entry in the css.



The project file can be downloaded here.

Please feel free to try this out and to post any comments if you have a better solution or if you like this one, or if you have additional solutions.

1 comment:

AIM88 said...

Cool