Data grid Line or Index

Bob Sneidar bobsneidar at iotecdigital.com
Wed Oct 29 12:38:45 EDT 2014


Normally that would be true, but Datagrids work differently. If you set the dgData of a data grid, given no sort, you will see that the dgDataOfLine and the dgDataOfIndex are identical. Element 1 is line 1 and Index 1. 

Now click one of the columns to resort. Element 1 is still line 1 but the index could be anything depending on how they sort. Or to put it another way, get the dgHilitedLine and the dghilitedIndex of a selected row. Now sort by another column. The line changes but the index remains the same. 

Now if you are getting the dgText, manipulating that, and then setting the dgText, of course the line and index will be the same for all rows when you set it. Reindexing will again scramble the indexes but the lines will be the display order. 

So you can say that the lines represent the current display order, while the index represents the order when the data was set. 

This is why I almost always use the dgHilitedIndex instead of the dgHilitedline. The only reason to use the line form is if you are processing data top to bottom in the displayed order. If you store the line, then allow the user to interact with the data grid, the stored line number will almost certainly be invalid. 

I think I’ve answered my question though. The array index would almost have to correspond to the current displayed order. 

Bob S


> On Oct 27, 2014, at 17:25 , Sri <sritcp at gmail.com> wrote:
> 
> Since arrays relate to how data is stored and not how data is displayed, I'd
> think no display-related factors should affect them. I'd expect dgData to
> stay the same (i.e., not updated), regardless of how the user manipulates
> the table displayed. (Any edits are incorporated through the index).
> 
> Regards,
> Sri.
> 
> 
> 
> --
> View this message in context: http://runtime-revolution.278305.n4.nabble.com/Data-grid-Line-or-Index-tp4685113p4685115.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode



More information about the use-livecode mailing list