Record index

Is it possible to have a calculation field that returns the record index?

It is probably very easy, but I don’t see it. :shock:

irenem:
Is it possible to have a calculation field that returns the record index?

Is the record index is the Selected Index? (if i am thinking right. :) )

If it is, Calculation fields(stored/unstored) are executed for each record. So Selected Index can be found by using getSelectedIndex() method under controller.

To do this, you should use a label, fill the text property with %%currentRecordIndex%% and make sure the “displaysTags” property is on.

Wow !! a Hidden Trick. :wink:

ars:
Wow !! a Hidden Trick. :wink:

Not hidden, just read the manual :)

Joas:

ars:
Wow !! a Hidden Trick. :wink:

Not hidden, just read the manual :)

oh!! missed the Servoy tag ‘%%currentRecordIndex%%’ :)

The idea is to be able to select multiple records in a list and deselect them by clicking somewhere else.

I thought to set the recordIndex in a global every time that the user clicks on a record. If the number in the global corresponds to the selectedIndex than an other bgColor is visible.

To set the bgColor I need a calculation field, and thats the problem, I can’t use controllers on calculation fields.

Keep in mind that recordIndex is relative to the position in the foundset. When your foundset changes or even being sorted differently a recordIndex changes.
If you want to create a multi-line select I suggest you work with the PK that you add to a global via a method.
To highlight a row you can easily use the rowBgColor calculation. See your form properties.

Hope this helps.

you are right, it works nice except when I want to set my global to NULL, it seems that it empties only the “global of that record”.

What I mean that it doesn’t update the global through the entire database.

I’m struggling with this also,

i just want a simple (non stored) calc that shows me the currentIndex in a tableview. ( I know, it changes, when you sort, or do other stuff, etc…)
because I can’t use: controller.getSelectedIndex() or foundset.getSelectedIndex() in a calculation, I thought I use this:

var vCurrentIndex = arguments[0]
return vCurrentIndex

if you use this as a rowcolor calculation, than the arguments[0] will give you the currentIndex
but this is not working when I use this calculation on a field in a table-view

anyone a solution?

I don’t know if that’s a “hidden feature”, unsupported or whatever, but this simple calc should work:

return currentRecordIndex;

thanks Patrick, that’s what I was looking for! :-)
It’s working great now

patrick:
I don’t know if that’s a “hidden feature”, unsupported or whatever, but this simple calc should work:

return currentRecordIndex;

In Servoy 6 this is unsupported and occurs a warning.
Does anybody know a solution for display the row numbers in a table view list?

Thomas