Data Grid Challenges

Michael Doub mike at doub.com
Fri Nov 18 12:48:44 EST 2011


I am trying to understand what is going on with data grids.   I have a stack with 2 cards each with a different data grid.   One is set up to have the card script populate the grid using the GetDataForLine technique the other sets the dgData property of the grid.   Below you can see the techniques used.   The data grids were set up manually but are identical in that the backgrounds and background boarders are set to different colours but with the same height of 35.   Both data grids are set to fixed height of 34 to overlap the boarder to only see a single boarder between rows.

There are 2 mysteries:
1)  The the grid on each card,  the colour of the row backgrounds are always set to white.  Not at all the colour of the template.  However, the colour of the row background boarders are set copied correctly from the template. 

2)  The second mystery is that the card using the GetDataForLine technique has two other problems.  The data is correctly being populated, but the row hight is set to size of the default template or 21; not the size of the edited template. With this incorrect size the slider does not work.  If you go into edit mode, then refresh the DataGrid the sizes are adjusted correctly, return to execute mode then the scrolling works properly.

I would really appreciate some help on this one.   There must be something really basic that I am missing.  The actual stack is here: http://dl.dropbox.com/u/43797494/test.livecode

Regards,
   Mike



Card 1  -------

on OpenCard
   lock screen
   set the dgNumberOfRecords of group "Contacts" to 20
   unlock screen
end OpenCard

on closeCard
    set the dgData of group "Contacts" to empty
end closeCard

command GetDataForLine pLine, @pOutData
   put "This line is : " into pOutData["FirstName"]
   put pline into pOutData["LastName"]
end GetDataForLine


Card 2  -------

on OpenCard
   put empty into tdata
   repeat with x = 1 to 20
      put " This is a test record: "into tdata [x]["FirstName"]
      put x into tdata [x]["LastName"]
   end repeat
   set the dgData of group "DataGrid" to tdata
end OpenCard

on closeCard
    set the dgData of group "DataGrid" to empty
end closeCard


Both data grids have the identical behaviour scripts. 


on FillInData pDataArray
    set the text of field "Label" of me to pDataArray["FirstName"] & pDataArray["LastName"] 
end FillInData

--left top right bottum
on LayoutControl pControlRect
   local x
   put  pControlRect into x
   put item 2 of x + 35 into item 4 of x
   set the rect of graphic "Background" to x
end LayoutControl

on ResetData
    set the text of field "Label" of me to empty
end ResetData







More information about the use-livecode mailing list