dgHilitedIndexes and dgHilitedLines in data grids

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

dgHilitedIndexes and dgHilitedLines in data grids

Post by keram » Fri Mar 07, 2014 5:46 am

Hi,

I need to clarify this question:

When a data grid is populated with let's say 100 lines each line gets an Index number which is dgHilitedIndexes when it's highlighted (suppose it's 17). Then if I sort out some of the lines and the remaining lines will populate the same data grid, will the same line K in the 2nd view when highlighted have the same Index number 17 as in the previous 1st view?

So far my understanding (maybe wrong) was that that the Index numbers of highlighted lines are fixed and Line numbers (dgHilitedLines) are changing according to what view the lines end up in. But I'm facing a problem with my dg that made me think it may not be so.

Can someone clarify?
Thanks.

keram
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: dgHilitedIndexes and dgHilitedLines in data grids

Post by keram » Fri Mar 07, 2014 6:05 pm

OK, no one responded...
Maybe my question is too complex or complicated?

So instead I posted a new topic showing practically how this problem shows up in a data grid. Here is the link:
http://ftp.runrev.com/forums/viewtopic.php?f=7&t=19476

keram
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: dgHilitedIndexes and dgHilitedLines in data grids

Post by dunbarx » Fri Mar 07, 2014 7:22 pm

Hi.

Except for Trevor deVore, most helpers need to think a bit about DG issues. I use them, but usually like to make a test on an actual gadget before I am comfortable answering a question. Someone will chime in...

Craig

Zryip TheSlug
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 163
Joined: Tue Jan 26, 2010 10:15 pm
Contact:

Re: dgHilitedIndexes and dgHilitedLines in data grids

Post by Zryip TheSlug » Sat Mar 08, 2014 12:01 am

keram wrote:Hi,

I need to clarify this question:

When a data grid is populated with let's say 100 lines each line gets an Index number which is dgHilitedIndexes when it's highlighted (suppose it's 17). Then if I sort out some of the lines and the remaining lines will populate the same data grid, will the same line K in the 2nd view when highlighted have the same Index number 17 as in the previous 1st view?

So far my understanding (maybe wrong) was that that the Index numbers of highlighted lines are fixed and Line numbers (dgHilitedLines) are changing according to what view the lines end up in. But I'm facing a problem with my dg that made me think it may not be so.

Can someone clarify?
Thanks.

keram
Hi Keram,

The question is more relatives to usage of arrays than usage of datagrids.

The dgIndexes of a datagrid are no more no less the keys you are preparing in the array used for populating the datagrid by using dgData.

Let's take an example with a datagrid of one key "myValue" composed by 5 rows:

dgData[index][key]

line 1 = dgData[1]["myValue"] -> A
line 2 = dgData[2]["myValue"] -> C
line 3 = dgData[3]["myValue"] -> B
line 4 = dgData[4]["myValue"] -> E
line 5 = dgData[5]["myValue"] -> D

the indexes sequence is: 1,2,3,4,5

If we are sorting the myValue by text ascending:

line 1 = dgData[1]["myValue"] -> A
line 2 = dgData[3]["myValue"] -> B
line 3 = dgData[2]["myValue"] -> C
line 4 = dgData[5]["myValue"] -> D
line 5 = dgData[4]["myValue"] -> E

the indexes sequence is: 1,3,2,5,4

The order of the keys changes, but the association index + value is the same.
Behind the index 5 we still have D, etc.

If we want to populate a datagrid with indexes 2 and 5 we just have to collect the data behind the indexes and we can preserve the same indexes if we want:

put tDataArray1[2] into tDataArray2[2]
put tDataArray1[5] into tDataArray2[5]

set the dgData of grp "myDataGrid" to tDataArray2

Content of the first datagrid:
line 1 = dgData[1]["myValue"] -> A
line 2 = dgData[3]["myValue"] -> B
line 3 = dgData[2]["myValue"] -> C
line 4 = dgData[5]["myValue"] -> D
line 5 = dgData[4]["myValue"] -> E

Content of the second datagrid:
line 1 = dgData[2]["myValue"] -> C
line 2 = dgData[5]["myValue"] -> D


Best Regards,
TheSlug
http://www.aslugontheroad.com - Tutorials, demo stacks and plugins for LiveCode
Data Grid Helper - An intuitive interface for building LiveCode's Data Grids
Excel Library- Extends the LiveCode language for controlling MS Excel

Post Reply