Update Non-editable field in edit mode

7 posts, 0 answers
  1. Paul
    Paul avatar
    1 posts
    Member since:
    May 2014

    Posted 10 Dec 2014 Link to this post

    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)?
  2. Alexander Popov
    Admin
    Alexander Popov avatar
    1444 posts

    Posted 12 Dec 2014 Link to this post

    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!
     
  3. Samra
    Samra avatar
    13 posts
    Member since:
    Feb 2017

    Posted 28 Jun 2017 in reply to Alexander Popov Link to this post

    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")

  4. Alexander Popov
    Admin
    Alexander Popov avatar
    1444 posts

    Posted 28 Jun 2017 Link to this post

    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.
  5. Samra
    Samra avatar
    13 posts
    Member since:
    Feb 2017

    Posted 28 Jun 2017 in reply to Alexander Popov Link to this post

    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;
                                                }
                                            };

  6. Samra
    Samra avatar
    13 posts
    Member since:
    Feb 2017

    Posted 28 Jun 2017 in reply to Alexander Popov Link to this post

    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

  7. Alexander Popov
    Admin
    Alexander Popov avatar
    1444 posts

    Posted 30 Jun 2017 Link to this post

    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.
Back to Top