Datagrid - adding line under variable height records

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Datagrid - adding line under variable height records

Post by Simon Knight » Fri Jan 02, 2015 4:38 pm

Hi,

Happy new year !

I am trying to display a line under a variable height field on a datagrid form. I have defined a line in the row template and attempt to move it in the Layoutcontrol handler. However, I have tried using the points of the line, the location of the line and the rectangle of the line but none have worked. The line gets moved but does not display for all records. My latest failure is listed below.

Code: Select all

  -- rect 1-left, 2-top, 3-right, 4-bottom
   -- Now place the line that acts as a record separation
   -- first increase the size of the record by six pixels
   put (item 4 of pControlRect +6) into item 4 of pControlRect
   
   put the points of graphic "MyLine" of me into tPoints  -- starting point for the size and position of line
   -- two points per line
   Put line 1 of tPoints into tStartCoOrd  -- X fom left , Y from top  
   Put line 2 of tPoints into tEndCoOrd
   
   put item 4 of pControlRect into item 2 of tStartCoOrd
   put item 4 of pControlRect into item 2 of tEndCoOrd
   put tStartCoOrd & CR & tEndCoOrd into tNewPosn
   set the points of graphic "MyLine" to tNewPosn
   
   -- resize the bounding rectangle to match the resized field
   set the rect of graphic "Background" of me to pControlRect
   ------
   
   SetForeGroundColor
end LayoutControl
best wishes
Skids

Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Re: Datagrid - adding line under variable height records

Post by Simon Knight » Fri Jan 02, 2015 4:46 pm

Hi,
My datagrid fails to display the graphic line if I make any attempt to move it, it may be something to do with refreshing the grid but using the following code I attempted to move the line 10 pixels to the right:

Code: Select all

-- Now place the line that acts as a record sep
   -- first increase the size of the record by six pixels
   put (item 4 of pControlRect +20) into item 4 of pControlRect
   
   --set the bottom of graphic "MyLine" to the bottom of graphic "MyLine" + 10
   set the right of graphic "MyLine" to the right of graphic "MyLine" + 10

   -- resize the bounding rectangle to match the resized field
   set the rect of graphic "Background" of me to pControlRect
   ------
only the first record displayed the line in its new location (ten to the right), when I refreshed the grid the line moved back to its original position as defined on the template. Any thoughts ?

best wishes

Simon K
best wishes
Skids

Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Re: Datagrid - adding line under variable height records

Post by Simon Knight » Mon Jan 12, 2015 1:58 am

I have a sort of answer: first do not alter the values in the string passed as pControlRect as it may cause problems. Second it seems to me that a line causes a problem because the datagrid does not allow a line to increase the height of a line in a form. My line has item 2 = item 4 in its rect which may also cause a/the problem. However, if I resize the background graphic before I move the line AND I position the line no closer than 2 pixels from the bottom of the graphic then the line is displayed. If I move the line first followed by the graphic then the line is not displayed.
best wishes
Skids

Post Reply