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

Update Non-editable field in edit mode

6 Answers 551 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 10 Dec 2014, 07:35 PM
I have a grid with a Duration field this is not editable and configured as so in the datasource schema. I have a Start Date and End Date in this grid, when the user enters or changes these dates the Duration value gets updated (EndDate - StartDate = x minutes). I have subscribed to the change event of the datasource and have been able to calculate the duration however i am not able to update the duration field. I have tried:

grid.dataitem("tr:eq(1)").set("Duration", value)

and as well as getting item by uid and doing the same but neither work. Is this possible with a non-editable field? Looking at the html there doesn't appear to be a control name (i may be wrong) so is the method to find the column cell and just update the content (though i'm not sure how to do this)?

6 Answers, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 12 Dec 2014, 01:20 PM
Hello Paul,

I already addressed this query in the support ticket you opened, but I will share my reply here as well.
This behavior is expected, because setting the field as non-editable prevents it from being updated through the set method as well. You can use the assignment operator and then manually trigger the change event as a workaround. For example:  
item.Duration = value;
item.trigger("change");

Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Samra
Top achievements
Rank 1
answered on 28 Jun 2017, 06:49 AM

This is exactly what i need with just one difference...instead of knowing the fieldname (Duration).

item.Duration = value

i have the field name in a variable so how can i set it?

var x = "Duration";

item.x = value

item.trigger("change")

0
Alexander Popov
Telerik team
answered on 28 Jun 2017, 01:52 PM
Hello Samra,

You can use the bracket object notation: 
var field = "Duration";
item[field] = value;
item.trigger("change");


Regards,
Alexander Popov
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Samra
Top achievements
Rank 1
answered on 29 Jun 2017, 12:53 AM

Firstly, Thanks for the quick response.. and secondly, this logic only works on columns where [editable: true] . Infact even dataItem.set() also works on those columns where editable is set to true.

The columns that have editable set to false do not budge...(I am setting editable property in the model.)

Also,on another suggestion from telerik I set 

editable: function (dataItem) {
      return false;
    }

in the model then there is invalid left-hand side assignment error.

fields["md" + mapdetailId + "rt" + resulttypeId] = {
                                            editable: function (dataItem) {
                                                return false;
                                            }
                                        };

0
Samra
Top achievements
Rank 1
answered on 29 Jun 2017, 12:57 AM

Thanks for a quick response Alexander. This logic is only working on columns that are set to editable in the model but not on non-editable columns. (I am setting editable property in the model not in columns as they donot work when i define in columns).

Also on another suggestion from telerik i set field in model as follows

fields["md" + mapdetailId + "rt" + resulttypeId] = {
                                            editable: function (dataItem) {
                                                return false;
                                            }

                                        };

instead of fields["md" + mapdetailId + "rt" + resulttypeId] = {
                                            editable: false
                                        };

Then it gives the error: Invalid left-hand side in assignment

0
Alexander Popov
Telerik team
answered on 30 Jun 2017, 12:22 PM
Hi Samra,

I am not sure what the exact scenario is. Would you please share a runnable Dojo example where it's replicated?

Regards,
Alexander Popov
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Paul
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Samra
Top achievements
Rank 1
Share this question
or