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

Bind column to a computed prperty

3 Answers 201 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kenneth
Top achievements
Rank 1
Kenneth asked on 05 Mar 2013, 04:20 AM
I have a grid with several computed columns.I set the computed properties when I change the properties in the grid edit mode . Do I need to use editor template to make a read only column (when I set editable:false it doesn't change according to the new value)? 

And I have several computed properties in grid, Is there any other way to make it a generic calculation instead of using if/else for change property name like this,

   
 save: function(data) {
     
        if (data.values.Qty) {
            var test = data.model.set("Total", data.values.Qty * data.model.Amt);
        }
        else {
            var test = data.model.set("Total", data.model.Qty * data.values.Amt);
        }
    }

Is there any event like saved (to get the data.model with changed property has been set)? 

And the other issue is when I have several computed fields set like this the save method is called for each calculated field set. 

Here is my example,
http://jsfiddle.net/H6tgv/74/

3 Answers, 1 is accepted

Sort by
0
Holger
Top achievements
Rank 1
answered on 05 Mar 2013, 09:22 AM
Do I need to use editor template to make a read only column (when I set editable:false it doesn't change according to the new value)? 

No, you can just set the editable property of the field in datasource's schema configuration to false.
0
Kenneth
Top achievements
Rank 1
answered on 05 Mar 2013, 11:31 AM
Yes, but then it doesn't change to the modified value if I set that after grid is loaded.
0
Holger
Top achievements
Rank 1
answered on 05 Mar 2013, 12:07 PM
You are right. According to this thread using a editor template (function) seems to be the only solution.
Tags
Grid
Asked by
Kenneth
Top achievements
Rank 1
Answers by
Holger
Top achievements
Rank 1
Kenneth
Top achievements
Rank 1
Share this question
or