Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
110
Different Cell Styles based upon row data
posted

I have a WebDataGrid where I want to have a different css style on a column based upon data in another column.  The idea is that I want to color the text red to highlight it if the value of another column in that row is set.  I can only find ways to set the entire column style.  Help?

Parents
  • 2680
    Verified Answer
    Offline posted

    Hello Rick,

    Thank you for contacting us.

    You can set the style using JS when the grid is rendered. Sample code snippet:

            function onWebDataGridIntialize(sender, args) {
                var rows = sender.get_rows();
                var rowsCount = rows.get_length();
                for (var i = 0; i < rowsCount; i++) {
                    var row = rows.get_row(i);
                    if (row.get_cellByColumnKey("UnitPrice").get_value() % 2 == 0) {
                        row.get_cellByColumnKey("Discontinued").get_element().style.backgroundColor = "red";
                    }
                }
            }

    I am attaching the working solution.

    Please let me know if you need anything else.

    ColoringRowCellBasedOnCondition.zip
Reply Children
No Data