Changing Grid Cell or Row Attributes on Condition

2 posts, 0 answers
  1. mvbaffa
    mvbaffa avatar
    102 posts
    Member since:
    Dec 2006

    Posted 04 Sep 2012 Link to this post

    Hi,

    I need to change the attributes of a grid  cell or row depending on some conditions. For instance I want to change the color of a cell or row or even make the editable fields of the row non editable.

    How can I do that ???

    Thanks in advance
  2. mvbaffa
    mvbaffa avatar
    102 posts
    Member since:
    Dec 2006

    Posted 06 Sep 2012 Link to this post

    I have found a partial solution,

    I could not change the the row attibutes but I could change a cell atribute. I did this way:

    In the column definition I defined a template pointing to a function like this:

    cols[6] = { field: 'currentAmount', title: 'Amount', format: '{0:c}', width: 80, template: formatAmount };

    The function is like this:

        function formatAmonut(o) {
         if (o.currentAmount < 0) {
                var div = '';
                div = "<div style='color:Red>" + o.currentAmount.toString() + '</div>';
                return div
            }
        }

    Of course if you an return a div you can set all styles you want. And more, i have not tried this but if you have a div I suppose you can create a Kendo Widget in this div. It is very flexible.

    Hope this helps.

  3. Kendo UI is VS 2017 Ready
Back to Top