0

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.

tamak
  • 1,541
  • 2
  • 19
  • 39
  • I'm not sure what you mean by "count". What are you counting? Are you referring to the index position of the item in your dataProvider? – JeffryHouser Feb 19 '13 at 00:24
  • i guess 'index position' is the correct way to refer to it.... so that as the items are positioned in the list component, the 'count' element is the number position that item holds... 1 for the first, 2 for the second, etc. etc. – tamak Feb 19 '13 at 00:32

2 Answers2

3

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;
}
JeffryHouser
  • 39,401
  • 4
  • 38
  • 59
0

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!

tamak
  • 1,541
  • 2
  • 19
  • 39