This is a migrated thread and some comments may be shown as answers.

Changing Grid Cell or Row Attributes on Condition

1 Answer 198 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mvbaffa
Top achievements
Rank 1
mvbaffa asked on 04 Sep 2012, 08:29 PM
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

1 Answer, 1 is accepted

Sort by
0
mvbaffa
Top achievements
Rank 1
answered on 06 Sep 2012, 06:19 PM
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.

Tags
Grid
Asked by
mvbaffa
Top achievements
Rank 1
Answers by
mvbaffa
Top achievements
Rank 1
Share this question
or