On Wed, Oct 19, 2011 at 10:56 PM, Mike Doub <m...@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode