Question

I have a list component that uses a sqlite database as the dataProvider and am able to use labelField to show the data labels just fine... I want to, however, affix an incremental count before the label field so its listed as

1.) item number 1 2.) item number 2 ... etc...

I discovered labelFunct and wrote the following to test it out:

private function lblFunct(value:Object):String
{
   return value.id + ") " + value.question;
}

and that shows the automatically assigned database ID before the label text just fine.... my goal is to try to get a COUNT of each item though... I can get the LENGTH of the data provider with

myListComponentID.dataProvider.length

but cant find any info on how to achieve an incremental count. is it possible to construct some sort of for each loop in the labelFunct? can anyone shed any light on this? Thanks in advance.

Was it helpful?

Solution

You're on the right track with the labelFunction. You can use getItemIndex method on your dataProvider to determine the itemIndex of the displayed item:

private function lblFunct(value:Object):String
{
   return myListComponentID.dataProvider.getItemIndex(value) + ") " + value.question;
}

OTHER TIPS

with help from the person who responded, I found my way to the solution... the fabel funct ended up looking like this:

private function lblFunct(value:Object):String
{
    return (myListComponentID.dataProvider.getItemIndex(value)+1) + ") " + value.question;
}

I added the +1 to compensate for the fact that its zero based. thanks to the responder though, you helped me find my way to the answer. Much appreciated!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top