DataGrid Cell Font Name? or Style?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
LC4iOS
Posts: 88
Joined: Tue Dec 03, 2013 8:15 pm

DataGrid Cell Font Name? or Style?

Post by LC4iOS » Tue Dec 17, 2013 7:26 am

Playing with the DateGrid as a simple table at the moment.
No Column Template
No Row Template

I'm displaying a Calendar and want to
change the Saturday and Sunday Columns to Italic and grey instead of black
change the current days cell FontName to something different and
Bold it and Red it

I've been thru the DataGrid Tour app, the API .pdf, Lessons, seached the internet.
But can't seem to finger it out.

Any help in the right direction would be cool.

Perhaps its an object something like:
dgProp["Column Style"] (1) --Saturday
dgProp["Column Style"] (2) --Sunday

then I don't know ...
Thanks to RunRev.
Thanks to LiveCode forum members.

LiveCode v5.5.5 - iOS Android Mac Windows - 6.5 Community
27" 2012 iMac i5, MacBook Pro, MacBook Air, iPhone 5, iPhone 4
xCode 5.0.2 - iOS7 - OS X Mavericks
Paid Apple iOS Developer Program Member

LC4iOS
Posts: 88
Joined: Tue Dec 03, 2013 8:15 pm

Re: DataGrid Cell Font Name? or Style?

Post by LC4iOS » Tue Dec 17, 2013 11:00 am

Is this close?
This is for bolding a row?

http://ftp.runrev.com/forums/viewtopic. ... 79&p=75350

Wow if that is Complete Beginners solution
I'm way out of my depth.


Looks easy here but gets complicated in the OP

Code: Select all

on mouseUp
   local tIndex, tColumn, tStyle
   put "Col 1" into tColumn
   put "bold" into tStyle
   
      put the dgIndexOfLine[the dgHilitedLines of group "DataGrid" ] of group "DataGrid" into tIndex
   
      dispatch "SetStyle" to group "DataGrid" with tIndex, tColumn, tStyle
end mouseUp
My bad. Drooling over this script blinded me and missed this was custom behavior.

Back to looking for something simpler tomorrow.

Please let me know if we can't do this without templates and custom behaviors.
Thanks to RunRev.
Thanks to LiveCode forum members.

LiveCode v5.5.5 - iOS Android Mac Windows - 6.5 Community
27" 2012 iMac i5, MacBook Pro, MacBook Air, iPhone 5, iPhone 4
xCode 5.0.2 - iOS7 - OS X Mavericks
Paid Apple iOS Developer Program Member

LC4iOS
Posts: 88
Joined: Tue Dec 03, 2013 8:15 pm

Re: DataGrid Cell Font Name? or Style?

Post by LC4iOS » Tue Jan 07, 2014 10:32 am

Just sharing:

Yeah, ok. After a decent Christmas and New Years Holiday.
Too easy to use CustomBehaviours.

Add a Custom Column Behavior to a dg Table:
Click on the Pointer+ tool to edit the card.
Double click on the dg to open the properties tool.
Select Columns.
Select the Column you want to add the Custom Column Behavior to.
(if Column Behavior ... button is grey click the + button next to it to add the Custom Column Behavior Script)
The script editor should pop up with the Custom Column Behavior Script.
Just click on the FillnData Routine name in the left panel.


and Try this:


Column "Sat" or "Sun"

Unless there is an easier way to set a Column BackGroundColor to Gray like in a single statement:

Code: Select all


on FillInData pData
    -- This message is sent when the Data Grid needs to populate
    -- this template with the column data. pData is the value to be displayed.
    
   -- Example:
    set the text of field 1 of me to pData
    
    set the opaque of field 1 of me to true   -- must set the opaque to true
    
    -- set the backGroundColor of field 1 of me to "White"  
    -- set the backGroundColor of field 1 of me to 0,0,0  -
    -- set the backGroundColor of field 1 of me to LightGray  

    set the backGroundColor of field 1 of me to Gray95  

    
end FillInData

Column "State" - colors, Bold,

Code: Select all

on FillInData pData
    -- This message is sent when the Data Grid needs to populate
    -- this template with the column data. pData is the value to be displayed.
    
    -- Example:
       set the text of field 1 of me to pData
   if pData = "ALASKA" then
      set the foregroundcolor of field 1 of me to Green
   else if pData = "ALABAMA" then
      set the foregroundcolor of field 1 of me to Green
      set the textStyle of field 1 of me to Bold
      else if pData = "TEXAS" then
      set the foregroundcolor of field 1 of me to Red
      --set the foregroundcolor of me to Red  --does NOT work here
end if

Column "CheckBoxfromFont" - wingdings font - unchecked = numtochar(168) - checked = numtochar(254)

NOTE: Following the LiveCode lesson for DataGrid CheckBox and the LiveCode Lesson DataGridHelper Checkbox are both better (and easier to use via Custom Column Behavior) than using Wingdings font characters

Code: Select all

on FillInData pData
   -- This message is sent when the Data Grid needs to populate
   -- this template with the column data. pData is the value to be displayed.
   
   -- Example:
   
   set the text of field 1 of me to pData
   set the textFont of field 1 of me to "WingDings"
   
end FillInData


Or maybe the script from the hyperlink in the previous post.
Thanks to RunRev.
Thanks to LiveCode forum members.

LiveCode v5.5.5 - iOS Android Mac Windows - 6.5 Community
27" 2012 iMac i5, MacBook Pro, MacBook Air, iPhone 5, iPhone 4
xCode 5.0.2 - iOS7 - OS X Mavericks
Paid Apple iOS Developer Program Member

LC4iOS
Posts: 88
Joined: Tue Dec 03, 2013 8:15 pm

Re: DataGrid Cell Font Name? or Style?

Post by LC4iOS » Fri Jan 10, 2014 6:10 am

Just sharing

Simple LiveCode DataGrid Table (not form) Calendar.
Using Column Behavior for each column.
And ForeGroundColor and textStyle for Red and Bold.
And Opaque and backGroundColor to hilite the current cell.

I used 7 column behaviors. 1 for each of the 7 days of the week.
Instead of the 4-5 row behaviors per month.
I tried to use Default Column Behavior but it would't return the dgHilitedIndexes used in GetDataOfIndex.
Attachments
stkDatGridCalendar_20140111 2010.livecode.zip
(9.48 KiB) Downloaded 198 times
Thanks to RunRev.
Thanks to LiveCode forum members.

LiveCode v5.5.5 - iOS Android Mac Windows - 6.5 Community
27" 2012 iMac i5, MacBook Pro, MacBook Air, iPhone 5, iPhone 4
xCode 5.0.2 - iOS7 - OS X Mavericks
Paid Apple iOS Developer Program Member

Post Reply