Data Grid Form TruncateTail Helper Function

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
dcpbarrington
Posts: 87
Joined: Tue Nov 13, 2007 6:40 pm

Data Grid Form TruncateTail Helper Function

Post by dcpbarrington » Tue Mar 10, 2015 6:23 pm

I have a Data Grid From that contains a field that I would like to indicate if the text is larger then the field.

Based on the Data Grid documentation I have there is a helper function called "TruncateTail" that can be placed in the Behavior Script to indicate if the text is larger then the field.

I've put the following code in both the FillnData and LayoutControl handlers, but no results.

Code: Select all

on FillInData pDataArray
   -- This message is sent when the Data Grid needs to populate
   -- this template with the data from a record. pDataArray is an
   -- an array containing the records data.
   -- You do not need to resize any of your template's controls in
   -- this message. All resizing should be handled in resizeControl.
   
   -- Example:
   if (pDataArray["label 1"] is a color) then
      set the backcolor of graphic "Background" of me to pDataArray["label 1"]
   end if
   
   -- Set the fields   
   set the text of field "name" of me to pDataArray["name"]
   set the icon of btn "select" of me to "6682"
   TruncateTail the short id of field "name" of me, "..."
   
end FillInData
   
on LayoutControl pControlRect
   local theFieldRect
   
   -- This message is sent when you should layout your template's controls.
   -- This is where you resize the 'Background' graphic, resize fields and 
   -- position objects.
   -- For fixed height data grid forms you can use items 1 through 4 of pControlRect as
   -- boundaries for laying out your controls.
   -- For variable height data grid forms you can use items 1 through 3 of pControlRect as
   -- boundaries, expanding the height of your control as needed.
   
   -- Example:
   put the rect of field "Label" of me into theFieldRect
   put item 3 of pControlRect - 5 into item 3 of theFieldRect
   set the rect of field "Label" of me to theFieldRect
   
   set the rect of graphic "Background" of me to pControlRect
   
   TruncateTail the short id of field "name" of me, "..."
   
end LayoutControl
I've tried it only in the LayoutControl or only the FillnData control and both and nothing works.
Is there something that I need to initialize to enable the helper functions or is this just code that needs to be defined in the handler.

Ideally I would like to reduce the font so the text fits in the field, but the text is already truncated before it gets to the handler as far as I can tell.

Thanks for the help.

Post Reply

Return to “Talking LiveCode”