Gridview with HTML code as text

Posted by: L10

Gridview with HTML code as text - 03/22/17 12:50 PM

Hi Everyone,

I want to add a this formula my gridview:

IF({quantity} >= 1, “<font size="4" color="green">In Stock</font>”, “<font size="4" color="orange">ETA 2-5 days</font>”

Where the result if true will be:
<font size="4" color="green">In Stock</font>

And if false:
<font size="4" color="orange">ETA 2-5 days</font>

However the quotes inside my html code for the true and false responses, break the formula. I need those in there for HTML, is there any way to ignore them?


Thanks
Posted by: Softrak Support

Re: Gridview with HTML code as text - 03/22/17 01:06 PM

Hi Lance,

Do you want the entire row in the GridView inquiry to have the conditional green/orange colour, or just the quantity column? Both of these can be accomplished without HTML.

For the entire row, create a named Row Format (from the Format menu) that uses a simple IF formula:

IF({quantity} >=1, "In Stock Green Style", "ETA 2-5 Days Orange Style")

where "In Stock Green Style" and "ETA 2-5 Days Orange Style" are named Styles in GridView that you create from the Format / Styles menu, creating font styles for size, colour, etc. Of course they can be named differently than this.

For just the specific quantity column, highlight that column in the grid and select Format / Conditional Styles. Ensure the Enable Conditional Styles checkbox is selected, and enter a similar formula:

IF(#>=1,"In Stock Green Style", "ETA 2-5 Days Orange Style")

where # simply represents the current column (ie the quantity).

Is there a particular reason why you wanted to use HTML?
Posted by: Retired_Guy

Re: Gridview with HTML code as text - 03/22/17 01:11 PM

Use the CHR(34) function for the Quote, like this:
Code:
IF({quantity} >= 1, 
    CONCATENATE(
     "<font size=",
     CHAR(34),
     "4",
     CHAR(34)),
   "FOO")


You need to replace every quote character you need with a call to CHAR(n).
Posted by: L10

Re: Gridview with HTML code as text - 03/22/17 01:28 PM

Yes, it needs to be HTML because this field gets uploaded to our website.

Thanks Andrew, it looks weird, but it works!

This was my final result:

Code:
IF({quantity} >= 1,
CONCATENATE("<font size=",CHAR(34),"4",CHAR(34),"color=",CHAR(34),"green",CHAR(34),">In Stock</font>"),
CONCATENATE("<font size=",CHAR(34),"4",CHAR(34),"color=",CHAR(34),"orange",CHAR(34),">ETA 2-5 Days</font>")
)