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
45
Multivalue converter and binding
posted

I am trying to set a value of a cell based on multivalue converter value. My converter returns boolean. If the return is true I want to set that particular cell with a static value and also set the color of that cell/row to red.

Please help.

  • 200
    Offline posted

    Hello Dhwani,

    Have you tried using column template for the desired column? The column template has option if a condition is true or false, and regarding the outcome to visualize different element.

    For example if you want to change the color to red of every id that is devisable by 3 your function may look like this:

    const columnShouldBeRed== function (id) {
        return id % 3 === 0;
    };
    

    Then you can set a template to change regarding the result from the "columnShouldBeRed" function:

    columns: [
    
       { key: "ProductID", dataType: "number", width: "200px",
    
       template: "{{if columnShouldBeRed(${ProductID}) }} " +
    
           "<div style='color: red;'>${ProductID}</div>" +
    
       "{{else}}" +
    
           "<div>${ProductID}</div>" +
    
       "{{/if}}" },
    
       ...
    
    
    ]
    

    I have attached sample for your disposal.

    In case you have additional questions feel free to contact me.

    templateGridSample.zip