addRowCss by condition

Hello. I want to apply css style for rows using condition. Style should depends on data in the cells of one column. I execute $('table').sort("#status#", "dsc", "string"); for sorting and after it I should apply css for each row. Cells of column #status# can be as 0, 1 or 2. Also I have other sort function but I should remove CSS before starting it and again apply CSS after execution $('table').sort("#status#", "dsc", "string");
My question is: how to apply addRowCss using condition on cells values in one column?

Tagged:

Comments

  • Hello @evgeny2k ,
    I suggest you attach onAfterSort event. The handler will take three parameters - template of sort-by field, direction of sorting and type of sorting. And depending on the direction of sorting apply the desired CSS.
    Please check the next snippet:
    https://snippet.webix.com/iiesbvwr

  • edited May 20

    Thank you for the response but I found another way. Each time before sorting I use

    $$('table').clearCss("bg1");
    $$('table').clearCss("bg2");

    and after it I use sorting like this:
    case 'Helpers first':
                $$('table').sort("#helper#", "dsc", "string");
                $$('table').eachRow(
                   function(row){
                        var item = $$('table').getItem(row);
                        if (item.helper == 0){
                            $$('table').addRowCss(row, "bg1");
                        }else{
                            $$('table').addRowCss(row, "bg2");
                        }
                   });
                break;

    P.S. In this example used only 2 possible cells values, 0 and 1.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!