Search these areas:
Help
Support Forums
Product Info



-Introduction
-DataWeb: What's New
-Creating an Application
-The DataWeb Designer
-Application Management
-Data Tables
-Data Tables
-Views
-Templates
-Components
-Data Analysis
-Members
-Security
-Importing
-Exporting
-FTP
-JavaScript
-Object Model
-Full-Text Search
-Domain and Email Hosting
-HotBlock Modules
-Account Management
-Glossary
-New Responsive UI Module





DataWeb Help
Support Forums
Tutorial
Script Library
Knowledge Base

Home > Support

Support Forum



Conditional text font color
KevinNicholls asked:
if record.bad == true, I want the font color of FieldX to be red in a grid - but field grid style in the format of  'color:##990000;'  - so I am having a hard time getting something like #record.bad == true?'color:##990000;'# to work.

I have tried escaping:
#record.bad == true?'color:\#\#990000;';#

and even string.fromCharCode():
#record.bad == true?'color:'+String.fromCharCode(35,35)+'990000;';#

Am I close?
Kev
 
  steveh responded:
  Could it be that you have not included the false case?  Try:

#record.bad==true?'color:##990000':'##f7f7f7;'#
 
  steveh responded:
  I mean:

#record.bad==true?'color:##990000':'##f7f7f7';#
 
  KevinNicholls responded:
  Still doesn't seem to work. My actual statement:

#record.translate=='NeedsUpdating'?'color:##990000':'color:##f7f7f7';#

tried to get anything to turn red:
#1==1?'color:##990000':'##f7f7f7';#
and also
#1==1?'color:##990000':'color##f7f7f7';#

no red anywhere.

Kev
 
  KevinNicholls responded:
  One more try- still no luck (red):
#1==1?'color:##990000;':null;#
 
  tamram responded:
  Try something like this (based on Northwind sample):

<ws:htmlblock>
<!--# 
record.Discontinued==1 ? response.write("<font style='color:990000'>" + record.ProductName + "</font>") : response.write(record.ProductName);
#-->
</ws:htmlblock>
 
  steveh responded:
  Hmm...
I assume this code is for the style attribute of a ws:field tag.  I guess what is happening is that you cannot dynamically set inline styles record by record.  Instead you are only allowed to set inline styles for the field as a whole.

You might try building a calculated field which reflects the color changing logic....
 
  KevinNicholls responded:
  Both good suggestions - but calculated fields and HTML blocks don't allow me to update the value (esp. in grid mode) - something I was looking to do here.

Kev
 
  KevinNicholls responded:
  Think I've got it:
#record.translate=='NeedsUpdating'?'color:'+String.fromCharCode(35)+'FF0000;':null;#

seems to work
(have to refresh grid after update to see color change);
 
  KevinNicholls responded:
  FYI-
The line above was copied in the Field Grid Style Box.

Kev
 
  dougl responded:
  I know you've already found a resolution, but reading through this thread, I notice you never tried a simple:

#record.translate=='NeedsUpdating'?'color:#FF0000;':null;#
 
  dougl responded:
  DataWeb considers this issue closed.
If you have additional questions or comments about this issue, please open it again.
If you have questions about a different topic please open a new support question.

Thanks,
DataWeb Support
 
  Please Log On
or create your own DataWeb Account.
Affiliate | Partner | Terms of Use | Privacy Policy | Contact Us | Pricing | Bring DataWeb In-House    
DataWeb, 720 North 10th Street, A #145, Renton, Washington 98057 *425-583-5970* Fax 484-770-4706* Email Us