Use of dgIndex

Mike Bonner bonnmike at gmail.com
Mon Nov 7 19:00:10 EST 2011


Theres a couple other things you'll have to track down to make this work.
 You are using dgdataofindex as your comparison, but if I understand how
the datagrid works in this respect that will use the internal index which
doesn't necessarily represent the visual (sorted) order of the data, so the
comparison will have strange affects when using it to display or hide your
header.

You'll want to use the dgDataOfLine instead.

I made some small changes to the fillIndata to get it to work. Didn't doc
the changes, too little time at the moment, but should be easy to find
them.

*on FillInData pDataArray*
*   put empty into fld "DLabel" of me*
*   if pDataArray["FirstName"] is not empty then *
*      put pDataArray["FirstName"] & space after fld "DLabel" of me*
*   end if*
*   if pDataArray["MiddleName"] is not empty then *
*      put pDataArray["MiddleName"] & space after fld "DLabel" of me*
*   end if*
*   put  pDataArray["LastName"] after fld "DLabel" of me*
*   put char 1 of fld "DLabel" of me into fld "HLabel" of me*
*   set the vis of fld "HLabel" of me to false*
*   set the vis of graphic "HBackground" of me to false*
*   put the dgControl of me into theGrid*
*   put the dgIndex of me into tindex*
*   if tindex is empty then *
*      put "error" into fld "HLabel" of me*
*      set the vis of fld "HLabel" of me to true*
*      set the vis of graphic "HBackground" of me to true*
*   else*
*      put the dgIndexes of theGrid into tlist*
*      set itemdel to comma*
*      put itemOffset(tindex,tlist) into myPosition*
*      If the dgindex of me = 1 then *
*         -- we have the first item so show a header*
*         set the vis of fld "HLabel" of me to true*
*         set the vis of graphic "HBackground" of me to true*
*      else*
*         put the dgline of me - 1 into previousIndex*
*         --item (myPosition -1) of tlist into previousIndex*
*         put the dgDataOfline[previousIndex] of me into theotherdata*
*         put  theotherdata["firstName"] & return after msg*
*         if the first char of theotherdata["FirstName"] <> the first char
of pDataArray["FirstName"] then*
*            -- we found a break so show a header*
*            set the vis of fld "HLabel" of me to true*
*            set the vis of graphic "HBackground" of me to true*
*         end if*
*      end if*
*   end if*
*end FillInData*

On Mon, Nov 7, 2011 at 4:38 PM, Michael Doub <mike at doub.com> wrote:

> That that did the trick.  I still get confused on these references.
>
> Thanks
>  Mike
>
>
> On 2011-11-07, at 6:26 PM, zryip theSlug wrote:
>
> > On Tue, Nov 8, 2011 at 12:12 AM, Michael Doub <mike at doub.com> wrote:
> >> Can someone explain to me where you are able to use the dgLine and
> dgIndex properties?   In the script below I am falling into the condition
> where no value is being returned for dgIndex.   Do I have a syntax problem?
> >
> > Mike,
> >
> > me not representing the theGrid. Me representing the behavior for a
> > cell in a datagrid row.
> > So you have to change the line:
> >
> > put the dgIndex of theGrid into tindex
> >
> > by:
> >
> > put the dgIndex of me into tindex
> >
> >>
> >> Thanks
> >>   Mike
> >>
> >>
> >> on FillInData pDataArray
> >>
> >>   put the dgControl of me into theGrid
> >>   put the dgIndex of theGrid into tinder
> >>
> >> end FillInData
> >>
> >> the complete stack can be found here to see the issue in actual
> operation:
> >>
> >> http://doub.com/test/test.livecode
> >
> >
> > Remember that I have uploaded a functional example on y website. You
> > are welcome to download it if it could help you in your task:
> >
> http://www.aslugontheroad.com/index.php?option=com_phocadownload&view=category&id=7:data-grid&Itemid=63
> >
> > The stack is named:
> > Experiment 022 - Alphabetic grouping
> >
> >
> >
> > 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
>
>
> _______________________________________________
> 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