Hi all,
I have a Data Grid in an iOS application, which can add new lines, delete any line, and sort lines. I understand that when a line is deleted, it actually removes the index of that line; so say I had 3 lines, and delete index 2, I still have index 1 and 3 even though they are now in lines 1 and 2. My problem is when I save the dgText of the Data Grid, and then reload them into the app upon launch, it resets the indexes of the data grid. Thus I now have index 1 and 2, instead of index 1 and 3. This is a problem because I have a seperate tab delimited data that refers to those indexes. And now the information is no longer synced up. Hopefully I explained that well enough, this is a question for a relative beginner, but will probably need an intermediate answer…
Thanks,
Jarren
Maintaining indexes of Data Grid
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Maintaining indexes of Data Grid
Hi Jarren,
Since the index is important to you I wouldn't delete the index but put empty into it.
Maybe put numToChar(65293) into the dgLine?
That could mess up the way it looks for you.
I think though that one shouldn't depend on the indexes being constant, a sort could screw them up. Have you thought of using multidimensional arrays? That way you could set an id to each of your items.
Simon
Since the index is important to you I wouldn't delete the index but put empty into it.
Maybe put numToChar(65293) into the dgLine?
That could mess up the way it looks for you.
I think though that one shouldn't depend on the indexes being constant, a sort could screw them up. Have you thought of using multidimensional arrays? That way you could set an id to each of your items.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Maintaining indexes of Data Grid
Thanks Simon, I think I figured out another way to do it. Basically adding another column and shoving the extra needed information inside does it. It's really thrilling to have found a simpler and more efficient way of doing something. 

Re: Maintaining indexes of Data Grid
Great news Jarren!
Finding your own way of doing things is one of the cool aspects of liveCode. Later you may find that you can improve on it but for now it's working and that's what counts.
Simon
Finding your own way of doing things is one of the cool aspects of liveCode. Later you may find that you can improve on it but for now it's working and that's what counts.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!