Row background color in dataTable control based on criteria

It is relatively straightforward to give a pattern of color to rows in a dataTable control, for instance to alternate colors from white to gray.
However, I have not yet figured how the row background color could be decided based on data fields associated with each row. For instance, I would like to set the row background color based on the value of a boolean attribute associated with the row, e.g. white if value is false and gray if it is true.
Is there an easy way to do this?
Martin

of the text, but not the whole cell. I need to find a
way to change the span at the row level (on the <tr>
tag). ANy ways to do this?
MartinThis is a question of how to let the renderer adjust its behaviour depending on the current state of the model. My renderer changes the background for the selected row by changing the style class:
        writer.startElement("tr", table);
          if (table.getRowSelector())
               if (table.isAtSelectedRow())
                    writer.writeAttribute("class", "selectedRow", null);
etc.(of course, to be able to do this you must write your own renderer)
erik

Similar Messages

  • How to change the background color of a cell based on other cell background

    Hi,
    Sorry if this is a basic question - I am new to XML. I want to create a table column, with no data in it. I then want to change the background color of the column based on the background color of other columns. I.E.
    - If there are 3 or less cells in this row that are not green, color this cell green.
    - If there are 4 or less cells in this row that are not green, and 3 or less are not red, color this cell yellow.
    - If there are 4 or less cells in this row that are not green, and 3 or more are red, color this cell red.
    If there are 5 or more cells in this row that are not green, color this cell red.
    Many thanks for any assistance.

    Okay - I have this resolved.
    1. Create two variables (Yellow and Red):
    <?xdoxslt:set_variable($_XDOCTX, 'Yellow', 0)?>
    <?xdoxslt:set_variable($_XDOCTX, 'Red', 0)
    2. For each cell, set the background based on their individual traffic light criteria, and update the associated color variable by 1. By default the backgrd color is set to Yellow so I only have to check for the lower and upper bounds:
    <?choose:?>
    <?when:number(CHECKED_IN)<=1?>
    <?attribute@incontext:background-color;'Lime'?>
    <?end when?>
    <?when:number(CHECKED_IN)>3?>
    <?attribute@incontext:background-color;'Red'?>
    <?xdoxslt:set_variable($_XDOCTX, 'Red', xdoxslt:get_variable($_XDOCTX, 'Red') +1)?>
    <?end when?>
    <?otherwise?>
    <?xdoxslt:set_variable($_XDOCTX, 'Yellow', xdoxslt:get_variable($_XDOCTX, 'Yellow') +1 )?>
    <?end otherwise?>
    <?end choose
    3. I now want a cell that is Red if any of the cells in the row is red. Its yellow of there are 3 or more yellow cells in the row, and no reds. Otherwise its green. First, create an empty cell and make the default color green. Then add:
    <?if: number(xdoxslt:get_variable($_XDOCTX,'Red')) > 0?>
    <?attribute@incontext:background-color;'Red'?>
    <?end if?>
    <?if: number(xdoxslt:get_variable($_XDOCTX,'Yellow')) >= 3 and number(xdoxslt:get_variable($_XDOCTX,'Red')) = 0?>
    <?attribute@incontext:background-color;'Yellow'?>
    <?end if?>
    4. Finally, reset the variables for the next row:
    <?xdoxslt:set_variable($_XDOCTX, 'Yellow', 0)?>
    <?xdoxslt:set_variable($_XDOCTX, 'Red', 0)

  • WorkOrderList TileView Row & Selected Row Background Color Change

    Hi,
         can we change the background color of WorkorderList TileView Row & Selected Row Background color ?. Actually i am trying to change the color of both in WorkOrderList but it not reflecting any color on my Agentry client. I used a style on Tile List View Data/Style.
    but these applied style on Rows & Selected Rows are not working in Agentry client.
    if any other alternate solution exist in Agentry, please guide me.
    i am using following...
      sap mobile platform-2.3.3
    Thanks & Regard
    Manish Kumar
    Tags edited by: Michael Appleby

    Hi Jason
          Yes using Image we can achieve that goal but i want to use a background color instead of Image background. Finally I used a background color on label and set the that label field on Screen. And It's showing the background color on WorkOrderList Row & Selected Row that what i wanted. But on both Row & Selected TileView Screen showing white outline that i don't want and also i could not remove the default Selected Blue Background Color.
         Please guide me how to remove white outline and default Blue Selected Background color.
    Thanks & Regard
    Manish Kumar

  • AdvancedDataGrid Row background color

    Hope someone can help, I wish to highlight an entire row or rows that match a value. I assumed the stylefunction would get me there but I have not found the style refering to the row background color.
    Any help please.
    Thank You

    The solution I found was to extend the data grid class, add override to the draw background and add a rowcolorfunction. When using item renderers you must use the style function with the alternatingItemColors so the renderer gets the color correct and not opaque.
    Thanks looking saisri2k2.

  • Change background color of a table based on table cell values quickly.

    Is there a more effecient way to change the background color of a table based on the cell values of the table?
    I can do this cell-by-cell using the property node, but it is very slow. It helps a little by deferring panel update, but it is still slow. Is there a better way? 
    Thanks.
    Ian

    If you want to color each cell according to the value, you need to do it one cell at a time and the above answers don't apply.
    You can dramatically speed up things by defering front panel updates for the duration of the operation.
    (sample code can be seen in the top picture here)
    EDIT: I noticed you tried this already. Can you show us your code?
    How many cells need to be colored on average?  If there are not that many, first write the background color using -2,-2, the only write the few cells to be colored, skipping the rest.
    How big is the table? If it is much bigger than the table indicator, all you need is to color the visible parts whenever the data or the scroll position changes.
    LabVIEW Champion . Do more with less code and in less time .

  • Advanceddatagrid grouped row background color

    Hi All,
    How to create a grouped row background color in advancedatagrid eg:
    Features
    Product 1
    Product 2
    Group1
       aa
    copy
    copy
       aa
    copy
    copy
    Group 2
       bb
    copy
    copy
       bb
    copy
    copy
    Thanks,
    srinath

    The solution I found was to extend the data grid class, add override to the draw background and add a rowcolorfunction. When using item renderers you must use the style function with the alternatingItemColors so the renderer gets the color correct and not opaque.
    Thanks looking saisri2k2.

  • Af:table: defining row background color based on a condition

    I want to display log objects (priority, name, detail) in a tab.
    The background color must be green for priority "DEBUG" and red for priority "WARN".
    It seems that in the table component, we can only control the column aspect and the output text inside...
    I'have read some posts (Franck N.) and it seems not possible to have an action of the row (all columns) background color...
    What can be the workarround ? other <af:?> component ???
    Is it now possible with the new JDEV11 components ?
    <af:table partialTriggers="pollRefresh" emptyText="No items were found"
    value="#{backing_logviewer.logViewerList}" var="log"
    rows="50">
    <f:facet name="detailStamp"/>
    <af:column sortable="true" headerText="Prio" formatType="text"
    sortProperty="prio">
    <af:outputText value="#{log.prio}"/>
    </af:column>
    <af:column sortable="true" headerText="Cat" formatType="text"
    sortProperty="cat">
    <af:outputText value="#{log.cat}"/>
    </af:column>
    <af:column sortable="false" headerText="Msg" formatType="text">
    <af:outputText value="#{log.msg}"/>
    </af:column>
    <af:column sortable="false" headerText="Thread" formatType="text">
    <af:outputText value="#{log.thread}"/>
    </af:column>
    <af:column sortable="false" headerText="Info" formatType="text">
    <af:outputText value="#{log.info}"/>
    </af:column>
    <af:column sortable="false" headerText="Log Date" formatType="text">
    <af:outputText value="#{log.logDate}" converter="dateConverter"/>
    </af:column>
    <af:column sortable="false" headerText="Throwable"
    formatType="text">
    <af:outputText value="#{log.throwable}"/>
    </af:column>
    </af:table>

    Thanks for your answer.
    Your solution is not working but if i put the styleclass instruction in the outputText element, it is working...
    Is there any other solution ???... because in this solution, we are obliged to put this EL in each outputText element of the tab.
    <af:column sortable="true" headerText="Cat" formatType="text"
    sortProperty="cat">
    <af:outputText value="#{log.cat}" styleClass="#{(log.prio == 'DEBUG') ? 'bgDebug' : (log.prio == 'WARN' ? 'bgWarn' : '')}"/> </af:column>

  • ADF Table row background color change ???

    Hi All
    i got below sql view object
    SELECT DEPARTMENT_ID,JOB_ID,COUNT(*) FROM EMPLOYEES GROUP BY DEPARTMENT_ID,ROLLUP(JOB_ID)
    By using this i will get each department_id, jobid's and total employes count in each department
    and i will get rollup for each departments ie i will get total employees.
    So i want to change the back ground of the total row.
    DepartmentId     JobId     Count1
    SA_REP 1
    1
    10     AD_ASST     1
    10     1 < this row in RED back ground in JSF page
    20     MK_MAN     1
    20     MK_REP     1
    20     2 < this row in RED back ground in JSF page
    30     PU_MAN     1
    30     PU_CLERK     5
    30     6< this row in RED back ground in JSF page
    40     HR_REP     1
    40     1< this row in RED back ground in JSF page
    50     ST_MAN     5
    50     SH_CLERK     20
    50     ST_CLERK     20
    50     45< this row in RED back ground in JSF page
    any kind of help is welcome...
    thanks
    Ravi

    Hi,
    you can do this by setting the background color of the outputText component that is the cell component e.g. in a read only table. Use the inlineStyle property to set the background-color but get the string from a managed bean. For each row you get a call to the managed bean and you can use JSF value binding
    FacesContext.getCurrentInstance().getApplication().createValueBinding()
    to access #{row} so that you can determine the value of a row column. Based on this you return a color
    Frank

  • How to set JTable row background color

    Hello,
    I have seen JTable with rows having alternate background color (mostly white and light blue). How can i set the same.
    Thanks,
    Deepak

    Well, i am new user to forum and so have no idea if this question has been asked previously "countless" times.Which is why you "search first" and "ask later". How to you expect to find out what valuable information is in the forum without learning how to do a simple search. This goes for any forum on the web you might use, so don't use the "I'm a new user" excuse.

  • Problem dynamically setting row background color in a report

    Hi guys,
    I want a PPR Classic SQL Report to dynamically show a background color depending on what value is stored in the column of the record.
    To illustrate what I've tried consider the following:
    1. I created a PPR Report on DEPT (this is the report I want to use with record backgrounds)
    2. I created a PPR javascript call that I trigger somewhere in the page
    function refreshReport(pField, pValue){
      var region = $v('P2_DEPT_RID');
      var link ='f?p=' + $v('pFlowId') + ':' + $v('pFlowStepId') + ':' + $v('pInstance') +'::::' + pField +':'+ pValue;
      html_PPR_Report_Page(this, region, link);
    The updating of the report works fine by the way.
    3. I changed the code in the HTML Expression of the column definition of "DNAME" of the DEPT report. I used jQuery to set the class of the <tr> element of the position the field is in.
    This is the value I want to dynamically check on
    <div id="dept_#DEPTNO#">#DNAME#</div>
    <SCRIPT type=text/javascript>
    $('#dept_#DEPTNO#').parent().parent().children().removeClass('t20data');
    if ('#DNAME#' == 'RESEARCH'){
          $(function(){    
            $('#dept_#DEPTNO#').parent().parent().addClass('voorhaal_kan');
    }else{
             $(function(){    
                $('#dept_#DEPTNO#').parent().parent().addClass('sscc_ok');
    </SCRIPT>4. I created some CSS like so:
    tr.voorhaal_kan{border:1px solid #AAA;border-left:none;border-top:none;background-color:#FFDD44;padding:2px 8px;}
    tr.sscc_ok {border:1px solid #AAA;border-left:none;border-top:none;background-color:#CCFFCC;padding:2px 8px;}
    tr.sscc_manco {border:1px solid #AAA;border-left:none;border-top:none;background-color:#FF3300;padding:2px 8px;}
    tr.sscc_geel {border:1px solid #AAA;border-left:none;border-top:none;background-color:#FFFF66;padding:2px 8px;}Now the problem is, the first time I load the page, the javascript in the HTML Expression works fine! It checks the value, and colors the <tr> beautifully. But, when i Refresh the report using PPR (calling the javascript function), the report is reloaded just fine, but the javascript bit in the HTML Expression is skipped for some reason resulting with a regular background color found in "t20Standard td.t20Data" . Alerts won't fire either in the code, hence the assumption of the code skipping.
    Any ideas on how this problem can be solved?

    Hey Rutger,
    I know you've already done a lot of work in another direction, but would it be possible for your purposes to use the SQL to do what you need. check out this link:
    How to perform a conditional column format based on column value
    and Conditional coloring of Database Column
    I hope those may help or give you other ideas.
    -Marc

  • Every other row (background color)

    I want to keep it simple and in css.  How can I get this to work properly so every other row has a yellowish background color with no gaps between the words.
    This is what I have but its producing an odd result.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
        margin: 0px;
        padding: 0px;
    div#footer{
        height:auto;
        background-color:green;
        clear:both;
        font-size:14px;
        width:800px;
    div#footer ul{
            margin:0;
            padding:0;
            list-style:none;
    div#footer li{
        width:155px;
        display:inline-block;
        text-align:center;
        vertical-align: top;
    /* horizontal line breaks */
    hr {
        border: 0;
        color: #323232;
        background-color: #323232;
        height: 1px;
        width: 95%;
        text-align: center;
    .even {
        background-color: #FF9;
    </style>
    </head>
    <body>
    <div id="footer">
            <ul>
            <li class="even">01/15/2011</li>
            <li class="even">Broadway Brewhouse</li>
            <li class="even">New Phila, OH</li>
            <li class="even">10pm</li>
            <li class="even">330-343-9231</li>
            <hr />
            <li>06/11/2011</li> <li>Edelwiess Inn</li> <li>Sugarcreek, OH</li> <li>10pm</li> <li>330-852-3750</li>    
            <hr />
            <li class="even">04/09/2011</li>
            <li class="even">Uhrichsville Moose Lodge (Open to the Public)</li>
            <li class="even">Uhrichsville, OH</li>
            <li class="even">TBD</li>
            <li class="even">740-922-9098</li>
            <hr />
            <li>01/15/2011</li> <li>Broadway Brewhouse</li> <li>New Phila, OH</li> <li>10pm</li> <li>330-343-9231</li>   
            </ul>
    </div>
    </body>
    </html>

    To create coloured backgrounds to every other row use this.
    #averages tr:nth-of-type(odd) {
      background-color:#ccc;
    Substitute the id of your table for mine and change the colour code to suit.

  • WAD - Portal - Changing row background colors

    Hi,
    We are creating web templates and posting to portal 6.0. I would like to know how to change the background colors for the rows for the output of the analysis item. Right now the default colors are grey and white (alternating rows). I did a search in the forum and it appears that there is no straightforward way to do it, with some suggesting we do it directly in the portal. Can someone provide detailed step by step instructions on how to change the background colors for rows for query output.
    Thanks,
    Anita S.

    You can modify the CSS (Cascading Style Sheet) in either Portal or WAD.  If you change it in Portal, it will be global for all reports viewed in the portal.
    For WAD, there is a general template parameter which contains the path to the .CSS file.  This CSS file is located in the Mime Repository (SE80).  Make the change to the css file in the mime repository and you're good to go.
    If you change the Portal CSS file, there is a wizard that can help you define colors for tables and preview them.

  • Set current row background color

    during post-query process, if record meets condition,
    i would like to set the color of entire line.
    thank you
    [email protected]

    Hi Jim,
    create a visual_attribute named e.g. PQR and set the desired background color.
    In post-query trigger:
    declare
         currec number := Get_block_property('block1', current_record);
    begin     
    if "condition" then
         set_item_instance_property('item1',     currec,visual_attribute,'PQR');
         set_item_instance_property('item2',     currec,visual_attribute,'PQR');
         set_item_instance_property('item3',     currec,visual_attribute,'PQR');
    end if;
    end;
    Good luck,
    Monica

  • Af:table rollup row background color change

    Hi All
    i got below sql view object
    SELECT DEPARTMENT_ID,JOB_ID,COUNT(*) FROM EMPLOYEES GROUP BY DEPARTMENT_ID,ROLLUP(JOB_ID)
    By using this i will get each department_id, jobid's and total employes count in each department
    and i will get rollup for each departments ie i will get total employees.
    So i want to change the back ground of the total row.
    DepartmentId     JobId     Count1
    SA_REP      1
    1
    10     AD_ASST     1
    10          1 < this row in RED back ground in JSF page
    20     MK_MAN     1
    20     MK_REP     1
    20          2 < this row in RED back ground in JSF page
    30     PU_MAN     1
    30     PU_CLERK     5
    30          6< this row in RED back ground in JSF page
    40     HR_REP     1
    40          1< this row in RED back ground in JSF page
    50     ST_MAN     5
    50     SH_CLERK     20
    50     ST_CLERK     20
    50          45< this row in RED back ground in JSF page
    any kind of help is welcome...
    thanks
    Ravi

    Ravi,
    I think I answered the same question on the JDeveloper forum. The way it goes is that you use the inlineStyle property on the outputText component(s) of the total row. If you hard code the color then all backgrounds are identical, if you use EL to reference a managed bean method to return the color then you can have conditional color rendering
    Frank

  • Change row background color or banding

    Can I do such things in my table? I'm working with a table which formatted subtotal. Now, I want to change the row color of each subtotal row. However, I can't find any attribute of row to do it.
    eg.
    ID
    10
    Dept1 100
    Dept2 100
    Subtotal 200
    20
    Dept3 200
    Dept4 300
    Subtotal 500
    Total 700
    Thanks in advance,

    Thanks Frank,
    I'm using OA Components Page in Oracle Application. It's .XML extension(I think you know it). I tried some ways to change the row color such as set row attribute, and change rowFormats of table like this
    processRequest
         tableBean.prepareForRendering(pageContext);
         //now get a handle on the array of Row Format Dictionaries
         DataObjectList myRowFormats = tableBean.getRowFormats();
         if(myRowFormats = null){
              DictionaryData[] myRowFormats = new DictionaryData[size];     
         //set the BANDING_SHADE_DARK property to TRUE for the second row
         //which corresponds to index 1 in the DictionaryData array
         rowFormats[1] = new DictionaryData(BANDING_SHADE_DARK,                          
    Boolean.TRUE);
         //Modify any other row formats
         tableBean.setRowsFormats(rowFormats);
    I found this on OAF Developer's Guide but it's not work out. Do you have any suggestion about it? Thanks for your time on this.

Maybe you are looking for

  • How to use Stored Procedure in RPD

    In the physical layer we have a option for procedure when we select a tables general tab.I created the procedure but i am not able to retrieve values in the Dashboard. Could anyone help me with this as how to use procedure.

  • How do I save a dvd (with video from a video camera) to edit with imovie?

    A friend took videos of an event of mine with his video camera. He then put the clips on a dvd and gave it to me. It was recorded on with a Sony video camera and imported on to a pc with vega's then burned with DVD Complete. He was not sure what form

  • New feature: HD Movies for download - question

    Curious - does anyone know what the specs are for the HD movie purchases? I believe on the rentals they are in AppleTV format which is the 940 x 540 size. Thanks. Steve

  • Page background, half disappeared?

    Hi gang, This occurs fairly regularly.  I've got a page background (a gradient).  The site is loading fine.  And then, when I sometimes do adjustments to a page ... the page background is not the FULL page, but only a portion of the page. I go back t

  • Notification Service OIM11g

    Hi Has any one tried out sending notifications using notification service using OIM 11g? When I am trying to send notification I am seeing exception like oracle.iam.notification.exception.TemplateNotFoundException: Cannot find the template. at oracle