onRecordSelectionByUser?

Some of my forms display in a tabpanel a list of records (table view) which the user can use to navigate to the desired record. Soemtimes the data is hierarchical, and so I provide several lists, one for the pareents, and one for the chidlren, such as in the attached example which lets users navigate among a 3-tier hierarchy of customers, locations and sublocations. Normally I would rely on onRecordSelection to detect my user changing records in these lists, but I’ve run into a problem with this. The problem is that when I want my CODE rather than the USER to navigate to a specific record, let’s say Location L and Sublocation S. As soon as I load the correct list of locations in the locations lists, Servoy selects the first location in the list and the onRecordSelection fires, even though I’m not yet on the correct location (L). Then once my code selects the correct location L, onRecordSelection fires again, this time doing the work I really need done.

To get around this I made my code select the correct location (L) in the customers_to_locations foundset before loading it into the locations form, but the selectedIndex didn’t stick.

So now what I do is I don’t use onRecordSelection in these lists, instead I put an onAction method on the fields in the list, and I do my work there. This way my code only executes when the USER changes records, and not when my CODE causes the record change. The only problem with this is that onAction doesn’t fire if the user uses arrow keys on the keyboard to change records in the list.

All of this may seem trivial but when there’s a lot of work being done by the onRecordSelection method, it’s important that it only gets executed when needed.

So my questions are:

Is there a better way of doing this that I’m missing? I’ve thought about using the treeControl but my customer likes this two-list approach.
Could Servoy implement a onRecordSelectionByUser event which fires ONLY when it was the USER that triggered the change, and not code
Could Servoy be made to REMEMBER the selectedIndex of a foundset when the foundset is loaded into a controller?
Alternatively, could Servoy implement onUpArrow and onDownArrow events that fire when the user changes rows in table/list views using arrow keys?

Thanks for your input.

There’s a couple of things you could do to workaround this…one would be a to use a global and check it in your record selection events. So your code would set “globals.disableRecordSelection = true”, and the first line of your onRecordSelection event could be “if(globals.disableRecordSelection) return;”

Then, of course you’d set it to false again at the end of you code.

There's a couple of things you could do to workaround this....one would be a to use a global and check it in your record selection events. So your code would set "globals.disableRecordSelection = true", and the first line of your onRecordSelection event could be "if(globals.disableRecordSelection) return;"

Then, of course you'd set it to false again at the end of you code.

Hi Greg. Thanks for your suggestion. I did try that for a while but I found it to be a rather awkward solution to the problem. I’m hoping that if others are also grappling with this issue, then with Servoy’s help we might arrive at something more elegant. If not, I may return to that approach.

I just remembered that another solution to this problem would be for Servoy to REMEMBER the selectedIndex of a foundset when the foundset is loaded into a controller. I have just added that to the wish list in my original posting.

amcgilly:
Alternatively, could Servoy implement onUpArrow and onDownArrow events that fire when the user changes rows in table/list views using arrow keys?

Adrian,

Servoy 4.2 ships a plugin for attaching methods to keyboard shortcuts, works in both web and smart cleint.

Rob