Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

iphone tableview index

hi guys,

i would like to know if i am able to create a dynamic index in the table view instead of hardcoding it.
i know that there is an example of index in a table in kitchen sink, but it is hardcoded.
is it possible that anyone can help me on it.

thank you!

— asked August 12th 2010 by Nicholas Chia
  • index
  • tableview
0 Comments

10 Answers

  • Accepted Answer

    ok

    Let's try this: http://www.pastie.org/1090469

    So I create an empty index array, and an empty temp_index array.
    In the for loop I check if the firstLetter exists in the temp_index, and if not I push it into the temp_array, and also create the entry in the index array.

    The code it's not tested but it should work.
    Let me know.

    — answered August 13th 2010 by Dan Tamas
    permalink
    0 Comments
  • What do you mean by dynamic ?

    You can create the rows in a for loop, depending on what vars you need, push each row to an array, then use this array as argument to setData().

    This is what you need?

    — answered August 12th 2010 by Dan Tamas
    permalink
    0 Comments
  • Hey Tamas,
    thnx for replying.

    what i copied from kitchen sink is actually the "table_view_headers_filters". its hardcoded but what i want is to actually go through my xml file and get
    e.g. substr(0,1) meaning the first letter of each word out and then throw them into an array so as to display on the right side index. i have also tried the for loop but it doesnt work, keeps on crashing.

    do u have sample code where i can reference for it?

    thanks in advance,
    Nicholas

    — answered August 12th 2010 by Nicholas Chia
    permalink
    0 Comments
  • So actually what's your issue? the xml parsing or the table? or both :)

    — answered August 12th 2010 by Dan Tamas
    permalink
    0 Comments
  • hi Tamas,

    xml parsing will be alright, i tink need help in the for loop and the table to create the index. my index meaning its at the right side of the table labeling from (A-Z). so when i click on e.g E it would go to the first word that starts with E.

    thanks in advance,

    Nicholas

    — answered August 13th 2010 by Nicholas Chia
    permalink
    0 Comments
  • Can you post a pastie with what you are doing?

    — answered August 13th 2010 by Dan Tamas
    permalink
    0 Comments
  • hi,

    check this

    http://www.pastie.org/1090312

    thks & regards

    — answered August 13th 2010 by Varun Atluri
    permalink
    0 Comments
  • Hi Varun, thnx i tried it but i cant get it working.

    Hi Tamas,

    this r my codes and wad i wan it in the image shack:
    http://www.pastie.org/1090367
    http://img716.imageshack.us/img716/5830/screenshot20100813atpm0.png

    in the image, the part where i highlight is what i want but i actually hardcoded it. but i am nt suppose to. do u have any idea for this?

    thanks in advance, Nicholas

    — answered August 13th 2010 by Nicholas Chia
    permalink
    0 Comments
  • Hi Tamas,

    the code works. thanks alot for all the help that u have given! appreciate it alot!

    thanks you!

    Nicholas

    — answered August 14th 2010 by Nicholas Chia
    permalink
    0 Comments
  • Great :) I'm glad I could help.

    — answered August 14th 2010 by Dan Tamas
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.