Changing text properties in a datagrid
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Changing text properties in a datagrid
Is it possible to set a line of text in a datagrid table to bold in a script. In other words the text would be left at default when defining the datagrid properties but be set to bold in some lines by a script depending on data conditions.
Thanks,
Pete
Thanks,
Pete
Re: Changing text properties in a datagrid
Thanks, that's what I needed.
Pete
Pete
Re: Changing text properties in a datagrid
Well I guess I spoke to soon!
The code I'm writing isn't executed from within the column behaviour scripts but as part of a button mouseUp event handler. It needs to be able to set all the text in certain lines in the datagrid to bold. It looks like it's the textstyle property that I need to use to get the bold setting but I can't figure out how to do that for the whole line. Do I ahve to set it for each column in the line individually and if so, how do I set about doing that?
Thanks,
Pete
The code I'm writing isn't executed from within the column behaviour scripts but as part of a button mouseUp event handler. It needs to be able to set all the text in certain lines in the datagrid to bold. It looks like it's the textstyle property that I need to use to get the bold setting but I can't figure out how to do that for the whole line. Do I ahve to set it for each column in the line individually and if so, how do I set about doing that?
Thanks,
Pete
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
Re: Changing text properties in a datagrid
I would add another, invisible column to your dgData array, let's call it "textStyle", and differentiate the column behavior on the basis of that entry.
Here's how I made a quick test stack for myself:
- create a new stack
- drop a datagrid onto it
- give it 4 columns
- for the first column, add a column template
- leave the template as is, but change its column behavior script, updating the FillInData handler to:
- use the Content panel of the Inspector palette to quickly add a few lines to the datagrid
- drop a button next to your datagrid, and set its script to:
- click the button, and 'lo and behold, the first column of the first row is now in bold
- as a bonus, you can use any valid combination of text styles, such as "bold,italic" and they will all be applied
Applying this textstyle-driven behavior script to each column, should do the trick.
HTH,
Jan Schenkel.
Here's how I made a quick test stack for myself:
- create a new stack
- drop a datagrid onto it
- give it 4 columns
- for the first column, add a column template
- leave the template as is, but change its column behavior script, updating the FillInData handler to:
Code: Select all
on FillInData pData
local tDataGrid, tIndex, tDataOfLine, tTextStyle
put the dgControl of me into tDataGrid
put the dgIndex of me into tIndex
put the dgDataOfLine[tIndex] of tDataGrid into tDataOfLine
put tDataOfLine["textStyle"] into tTextStyle
set the textStyle of field 1 of me to tTextStyle
set the text of field 1 of me to pData
end FillInData
- drop a button next to your datagrid, and set its script to:
Code: Select all
on mouseUp
local tDataOfLine
put the dgDataOfLine[1] of group "Datagrid 1" into tDataOfLine
put "bold" into tDataOfLine["textStyle"]
set the dgDataOfLine[1] of group "Datagrid 1" to tDataOfLine
end mouseUp
- as a bonus, you can use any valid combination of text styles, such as "bold,italic" and they will all be applied
Applying this textstyle-driven behavior script to each column, should do the trick.
HTH,
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
Re: Changing text properties in a datagrid
Excellent, thanks Jan.
Pete
Pete