CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Color in Cell

Print topic Send  topic

Author Message
ciberlin

Posts: 25
Posted: 10/09/2004, 11:45 AM

How can I put a color on a cell based on a value.
For example if the value is "Effective" the cell insted of showing up with the text "Effective" it will show up green inside. If the condition is other thatn "Effective" the the cell will be Red.

ASP, SQL, IIS

Thanks in advance
View profile  Send private message
Karsten


Posts: 57
Posted: 10/09/2004, 1:38 PM

look/search in CCS helpfile, there is an example showing how to change a
tabelcells color on a condition


Karsten

_________________
If one gives up, he told himself he failed.
View profile  Send private message
ciberlin

Posts: 25
Posted: 10/09/2004, 3:17 PM

The one I saw in the help files is for alternate row color, witch applie to the cell but what I need is a color based on a value,

any ideas
View profile  Send private message
Karsten


Posts: 57
Posted: 10/09/2004, 3:41 PM

hi ciberlin

yes, i have an idea.

its nearly the same like the one with the alternate rowcolor
there is also an "error" in the helpfile if you look keen, you see the tags
<td> are used wich are the celltags not the <tr> wich are the rowtags

its all the same just use the right tag and the right event
in the event ask "if negative use class red if positive use class green"

its just easy, i wrote you a PM , maybe you want to remotely working with me show me your project and we fix it together?




_________________
If one gives up, he told himself he failed.
View profile  Send private message
peterr


Posts: 5971
Posted: 10/10/2004, 6:28 AM

Here is an example of how to change a text's color:
http://docs.codecharge.com/studio/html/QuickStart/Creat...FieldValue.html

I haven't tried changing the color of a cell, but possibly you could highlight the text with another color, or include a color cell (1-cell table) within cell, etc.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
ciberlin

Posts: 25
Posted: 10/10/2004, 8:57 AM

thank you I will ttry and let you know
View profile  Send private message
dataobjx


Posts: 181
Posted: 10/12/2004, 5:07 AM

You can also used a technique demonstrated in Issue #1 of CCS Developer Magazine. You can download issue #1 of CCS Developer Magazine FREE by registering at www.dataobjx.net. Full source code for the articles is supplied for the articles in the magazine.

Feel free to download some of the resources/tools while you're on-line.
_________________
www.DataObjx.net
www.mydigitalapps.com
View profile  Send private message
ciberlin

Posts: 25
Posted: 10/12/2004, 11:01 AM

Quote dataobjx:
You can also used a technique demonstrated in Issue #1 of CCS Developer Magazine. You can download issue #1 of CCS Developer Magazine FREE by registering at www.dataobjx.net. Full source code for the articles is supplied for the articles in the magazine.

Feel free to download some of the resources/tools while you're on-line.

I try yours but no luck,
I try and try diferent ways and still no luck.
I have a grid call daily1 in the grid is a lablel in a cell call effective.
if the value of the effective lable is Effective the cell needs to go green if is other thant Effective needs to go Red.

I will keep trying anyway but I take any ideas.
thanks in advance
View profile  Send private message
ciberlin

Posts: 25
Posted: 10/12/2004, 2:25 PM

Here is my before show code
after I change the values on the DB from Effective to 1,2 or 3 valuse

'Custom Code @239-73254650
' -------------------------
Dim NumUnitsInStock
Dim sStyle

sStyle = "NoMarksDataTD" 'Default Style

NumUnitsInStock = daily1.datasource.recordset.fields("effective")

'handle any null values
If Len(NumUnitsInStock) = 0 Then NumUnitsInStock = 0

If NumUnitsInStock < 6 Then
sStyle = "NoMarksRedDataTD"
ElseIf NumUnitsInStock > 6 And NumUnitsInStock < 21 Then
sStyle = "NoMarksDataTD"
ElseIf NumUnitsInStock > 20 And NumUnitsInStock < 51 Then
sStyle = "NoMarksYellowDataTD"
End If

daily1.Hidden1.value = sStyle
' -------------------------
'End Custom Code



here is my grid row

<!-- BEGIN Row -->
<tr>
<input style="WIDTH: 65px; HEIGHT: 22px" type="hidden" size="8" value="{Hidden1}" name="{Hidden1_Name}">
<td class="NoMarksDataTD">{line} </td>
<td class="NoMarksDataTD">{acftid} </td>
<td class="NoMarksDataTD">{takeoff} </td>
<td class="NoMarksDataTD">{tekeoffact1} </td>
<td class="NoMarksDataTD">{dev1} </td>
<td class="NoMarksDataTD">{dev1cc} </td>
<td class="NoMarksDataTD">{effective} </td>
<td class="{Hidden1}">{remarks} </td>
</tr>
<!-- END Row -->


View profile  Send private message
ciberlin

Posts: 25
Posted: 10/12/2004, 3:52 PM

I even try to copy the task example that based on the priority an arrow with diferent colors show up. But no luck in this side.
View profile  Send private message
peterr


Posts: 5971
Posted: 10/13/2004, 3:19 AM

Hi,

Hidden field probably cannot work here, since Hidden is an INPUT control, not a text. See http://www.w3.org/TR/REC-html40/interact/forms.html#edef-INPUT
I would use a Label instead.

Or you could completely remove <td class="{Hidden1}"> and instead in your code replace {remarks} with "<td class=something" + (value of the remarks field).
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
dataobjx


Posts: 181
Posted: 10/13/2004, 5:54 AM

The NumUnitsInStock = daily1.datasource.recordset.fields("effective") is not correct - if it's really a Number of Units In Stock value.

You'd may need to perform a CCDLookup like this to get the number of units in stock;

Dim lngProductID
lngProductID = daily1.datasource.recordset.fields("product_id_field")

If Len(lngProductID) > 0 Then
NumUnitsInStock = CCDLookup("UnitsInStockFIELD", "PRODUCTS_TABLE_NAME", "product_id_field=" & CCToSQL(lngProductID, "Integer"), DBIntranet)
End If

Changing the value from a 1 to a 2 or a 3 will always execute the following line;

If NumUnitsInStock < 6 Then
sStyle = "NoMarksRedDataTD"....

Consequently always giving you the same style.

For example, try this with the code to see whether the value is properly changing...

Dim NumUnitsInStock
Dim sStyle

sStyle = "NoMarksDataTD" 'Default Style

NumUnitsInStock = 16 'daily1.datasource.recordset.fields("effective")

'handle any null values
If Len(NumUnitsInStock) = 0 Then NumUnitsInStock = 0

If NumUnitsInStock < 6 Then
sStyle = "NoMarksRedDataTD"
ElseIf NumUnitsInStock > 6 And NumUnitsInStock < 21 Then
sStyle = "NoMarksDataTD"
ElseIf NumUnitsInStock > 20 And NumUnitsInStock < 51 Then
sStyle = "NoMarksYellowDataTD"
ElseIf NumUnitsInStock > 51 Then
sStyle = "NoMarksStandardDataTD"
End If

response.write sStyle & "/" & NumUnitsInStock
Response.end

'daily1.Hidden1.value = sStyle

Manually change the NumUnitsInStock value from 3 to 18 to 21 and finally 100.

Notice also that I added another line to the If statement;

ElseIf NumUnitsInStock > 51 Then
sStyle = "NoMarksStandardDataTD"

Once you can see the style name/NumUnitsInStock values being written to the page, then remark/un-remark the lines as shown below.

Leave the manual setting for the NumUnitsInStock in place for the moment and manually change the number as you perform this test.


'response.write sStyle & "/" & NumUnitsInStock
'Response.end

daily1.Hidden1.value = sStyle

This will allow the page to execute fully again.

After it executes, perform a right click view source on the page.

You should see the following (based on what value you're using for NumUnitsInStock) - also note that you are only transposing the 'remarks' file in your code... you may want the entire row to change color instead and will need to put class="{Hidden1}" on each TD.

<tr>
<input style="WIDTH: 65px; HEIGHT: 22px" type="hidden" size="8" value="{Hidden1}" name="{Hidden1_Name}">
<td class="NoMarksDataTD">{line} </td>
<td class="NoMarksDataTD">{acftid} </td>
<td class="NoMarksDataTD">{takeoff} </td>
<td class="NoMarksDataTD">{tekeoffact1} </td>
<td class="NoMarksDataTD">{dev1} </td>
<td class="NoMarksDataTD">{dev1cc} </td>
<td class="NoMarksDataTD">{effective} </td>
<td class="APPROPRIATECLASS FROM IF STATEMENT">{remarks} </td>
</tr>

Again depending on the value your manually using for the NumUnitsInStock value you should see the applicable class value being written to the TD.

Finally, ensure that the styles exist and the stylesheet is included.

If all of this fails, send your code toadministrator@dataobjx.net and we'll have a look at it closer and fix it for you...
_________________
www.DataObjx.net
www.mydigitalapps.com
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.