Resizable DataGrid Question

Mike Doub Mike at Doub.com
Wed Oct 19 18:34:07 EDT 2011


I am not sure that you can assume that the indexes always going to
correspond to the display order.  This is why I decided to use dgIndex
function as it returns the indexes in the display order.   I do plan on
having multiple sorting options.

This still does not explain why I am not getting any results at all using
the dgIndex function.   Could this be a platform issue if my syntax is
correct?  I am using Windows XP.  

-= Mike

-----Original Message-----
From: use-livecode-bounces at lists.runrev.com
[mailto:use-livecode-bounces at lists.runrev.com] On Behalf Of zryip theSlug
Sent: Wednesday, October 19, 2011 5:44 PM
To: How to use LiveCode
Subject: Re: Resizable DataGrid Question

On Wed, Oct 19, 2011 at 10:56 PM, Mike Doub <Mike at doub.com> wrote:
> I believe that I have found a way to get the previous grid item, but I 
> must have the syntax incorrect for getting the dgIndex of me.   
> Nothing is being returned.  Can any DataGrid experts give me any guidance?
>
> Thanks
>   Mike
>
>
> on FillInData pDataArray
>   set the text of field "Name" of me to pDataArray["LastName"] & \
>         comma & space & pDataArray["FirstName"] & space & 
> pDataArray["MiddleName"]
>   put char 1 of fld "Name" of me into field "spacerLable" of me
>   put the dgControl of me into theGrid
>   put the dgIndex of me into tIndex
> -- get the index of the current grid item
>   put the dgIndexes of me into tList
> -- get list of grid indexes in display order
>
>   put itemoffset(tIndex,tList) into toff --find the current index in 
> the ordered list
>   put item (toff -1) of tList into tpreIndex
> -- get the index of the previous grid item
>   if tpreIndex = 0 then
>
>      set the visiable of group "spacer" of me to true
> -- we are the first grid item, so show the spacer
>   else
>      put the dgDataOfIndex[tpreIndex] of me into preData         -- 
> get the data for the previous grid item
>      if char 1 of preData["LastName"] = field "spacerLable" of me then
>         set the visiable of group "spacer" of me to false
> -- no difference yet
>      else
>         set the visiable of group "spacer" of me to true
> -- we found a difference
>      end if
>   end if
> end FillInData


Hi Mike,

Your syntax for dgIndex seems correct. However, if you allow me, you could
have done this with less code:


on FillInData pDataArray
   put pDataArray["LastName"] & \
      comma & space & pDataArray["FirstName"] & space &
      pDataArray["MiddleName"] into tCurrentName
   set the text of field "Name" of me to tCurrentName
   put the dgIndex of me into tTheIndex
   put (the dgIndex of me - 1) into tThePreviousIndex
   if (tThePreviousIndex > 0) then
      put GetDataOfIndex(tThePreviousIndex, "LastName") into tPreviousName
   end if
   if ((first char of tCurrentName is not first char of tPreviousName) or
(tThePreviousIndex is 0)) then
      set the visible of group "spacer" of me to true
   else
      set the visible of group "spacer" of me to false
   end if
end FillInData


Best regards,
--
-Zryip TheSlug- wish you the best! 8)
http://www.aslugontheroad.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