Unable to reset the edited field to its Original value

2 posts, 0 answers
  1. nischal
    nischal avatar
    1 posts
    Member since:
    Dec 2015

    Posted 08 Jan Link to this post

    When i edit the end date field and set to the some new date, onSave it does not retain its original value using .set method,

    Or any other field for that case, if i edit and onSave if i try set the old value It will not set , (will not reflect in the UI)


      $scope.ganttOptions = {

              dataSource: $scope.ganttDataSource,
              dependencies: $scope.ganttDataDependency,
              columns: [
                { field: 'id', title: "Task ID", width: 50, sortable: true},
                { field: "title", title: "Title", width: 100, sortable: true, editable: true },
                { field: "days", title: "Duration", type: "number", width: 50, editable: true},
                { field: 'start', title: "Start", sortable: true, format: "{0:MM/dd/yyyy}", width: 100, editable: true },
                { field: 'end', title: "End", sortable: true, format: "{0:MM/dd/yyyy}", width: 100, editable: true },             
                { field: 'percentComplete', title: '%', width: 50, editable: true},
               views: [
                        { type: "month", selected: true },
              add: onAdd,
              edit: onEdit,
              cancel: onCancel,
              save: onSave, 

    //Scenario 1

    function onSave(e){  

         if(e.values.end != undefined){

              //Few code here, based on conditions and new values that i get

              //In the end i set the end date to its original value 

             //This does not work

              e.task.set("end", e.task.end);    //e.task.set("end", new Date("03/16/2016"));


    //Scenario 2

    function onSave(e){

       if(e.value.end != undefined){

         //This way it works, cus edited field is end date and some value is set to days field. 

          e.task.set("days", 12);



  2. Dimitar Terziev
    Dimitar Terziev avatar
    1266 posts

    Posted 12 Jan Link to this post


    The reason for the experienced behavior is the following. When a task is updated the values from the event argument are applied to the task fields, so in order to restore a particular field then the e.values object should be altered as shown below:
    function onSave(e) {
        if (e.values.end != undefined) {
            e.values.end = e.task.end;

    Dimitar Terziev
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top