Forums

Find answers, ask questions, and connect with our
community all around the world.

Home Forum Omnis General Forum Data grid – Turning cells ‘red’

  • Data grid – Turning cells ‘red’

    Posted by Allan Sullivan on May 9, 2023 at 2:15 pm

    I have a question about data grids in a web application.

    The data grid is a standard data grid control. It is populated from a list. Most of the data in the grid will be black; however, we would like certain (individual) cells to appear in red, depending on the data that exists in the cell. (In this case, it is a numeric/dollar value that we want showing up in red if it is negative.)

    This is using Omnis 10.22.

    Thanks in advance.

    Andreas Pfeiffer replied 1 year, 2 months ago 4 Members · 3 Replies
  • 3 Replies
  • Silvan Baach

    Member
    May 9, 2023 at 2:34 pm

    I have no experience with the Data Grid Web Control but I think you have to turn the $columnstyledtext property to kTrue for the column you want to display the red text. After that you can make your values appear red via the style function. E.g myList.$add(con(style(kEscColor,kRed),’MyValue’,style(kEscColor,kBlack)))

  • Franco Maregotto

    Member
    May 9, 2023 at 4:47 pm

    Allan

    Coloring a grid is something I do a lot..

    try this:

    For iList.$line from 1 to iList.$linecount step 1

    If iList.yourcellValue>0

    Do $cinst.$objs.MainPane.$objs.jsGrid.$objs.myField.[iList.$line].$textcolor.$assign(kJSThemeColorPrimary)

    Else

    Do $cinst.$objs.MainPane.$objs.jsGrid.$objs.myField.[iList.$line].$textcolor.$assign(kRed)

    End For

    HTH

    Franco

  • Andreas Pfeiffer

    Administrator
    May 9, 2023 at 5:55 pm

    Hi Allan,

    You can use $rowcsscol property of the grid. This allows you to specify an extra column in your list that takes the name for a CSS class which can change the color of your list lines.

    Check out the „row styles“ section in the documentation: https://www.omnis.net/developers/resources/onlinedocs/WebDev/03jscomps.html#row-styles

    Best,

    Andreas

Log in to reply.