Detect list selection
In a table view/list, select a row and the form slides out. One can move the selection up and down the list and the form data changes to reflect the selected row. Standard Ninox behaviour.
Is there any way to detect when a (different) row is selected? Basically a trigger when the row selection changes?
42 replies
-
That's it. The modules have to be loaded by a formula field in that table, or the onselected() function doesn't run, even though the JS calc still works.
When the modules are loaded by that initialisation routine all using a different table, onselected() doesn't run when used in other tables.
Your example shows it all working in that same table, so the problem did not arise.
-
Ok, your example works for me. So I considered the difference from my db.
I added an onselected() function (that does nothing of any use) in my initialisation table. Then onselected() DOES work in other tables.
So I removed that function from the initialisation table in your test db. It still worked.
I removed it from my db and it worked.
About the only consistency is that if I open that initialisation record automatically on load, onselected() then doesn't work in other tables.
If I don't run it on load and just open that table manually after the db is loaded, then onselected() works.
I need to look further at the differences between my db and your test one. Have to look into that tomorrow.
-
I've not tried it loading on open, but just loading them manually is causing a problem. I have a formula field which is not updating when switching records. So if I go to table, click record in list and the formula shows correct. Select a different record (previous next etc) and the formula field is not always correct. Sometimes blank and sometimes shows the value from the previous record. If I show that formula field in the table/list view, that column (and any others based on it) simply go blank.
I exited the db and loaded again, without loading your modules and this problem does not occur. So your modules is causing this.
It's as if the onSelected() function is filtering out some of the events that Ninox normally sees and uses to update stuff when the selected record changes.
The formula field is using a child table in the calculation. If I remove the formula field all looks ok, so this may have always been an issue with the modules and only now apparent due to the introduction of the formula.
Anyway, definitely works perfectly if modules not loaded.
-
Well it's a bit weird, but the good news is that the latest version of your modules seem to load perfectly using 'Trigger on open' and onselected() is doing what it should. So well done Jacques and thank you.
What is weird is that the formula field was getting screwed by the code run in onselected(). There are 2 parts to that, both of which set some 'memory' fields. One is global and the other is per record. They are used in child tables in order to access values not normally accessible to them. The code works and all is good, BUT…
The formula field causing the trouble does some array manipulation based on the children of this main table, not actually connected to the memory fields previously mentioned. Again, that formula field works fine, as it should, until the code that sets either of the memory fields is run and then the formula field displayed in the main list/table view blanks out, on one or more rows, although the formula field usually still looks correct on the form if open. So a complete discrepancy between the same (formula) field shown on the form and in the list.
Redrawing the main list puts things right and the formula field again shows correctly - until the memory field code is run again. And so on.
So I eliminated the formula field by instead setting a Text field when the child table is updated. Needless to say, that field is not affected by any code being otherwise run.
I can only assume it is a Ninox bug where it is not correctly updating all it should and when it should. Fortunately, in the end I found a way around it and with Jacques' module working well, everything is working as Ninox should, but currently doesn't due to an obscure bug and a lack of user control of the interface events, both of which should really be addressed by Ninox.
Content aside
- 2 yrs agoLast active
- 42Replies
- 678Views
-
3
Following