Reset one edited cell of grid

272 Views Asked by At
  • I have 3 edited cell in row and 3 reset button in witch 2 reset button is for 2 individual cell and 1 is for whole row reset.

  • For reset whole row i used grid.store.getAt(rowIndex).reject().

  • I don't know what i use for reset particular cell.

1

There are 1 best solutions below

0
KaranPithadiya On BEST ANSWER

I found the Solution.

  • I used row wise reset button, in witch 1 reset button is for Cell_2 and another reset button is for Cell_3 and 3rd reset button is like global reset for whole record.
  • I do grid.store.getAt(rowIndex).set("Cell_2",""); code for Cell_2 and Cell_3 reset button.
  • " hasUnsavedChanges() " call for check any unsaved changes is available or not while leave from that row OR that menu.
  • If unsaved changes is available then Show popup and not available then remove that record from store modified list.
hasUnsavedChanges: function() {
      var isCell_1modified = false;
      var isCell_2modified = false;
      var isCell_3modified = false;
      this.getParametersFormPanel().stopEditing();
      var rowIndex = this.getParametersFormPanel().getSelectionModel().lastActive;
      var storeDataRecoder = this.getParametersFormPanel().getStore().data.items[rowIndex];
      var modifiedRecord = this.getParametersFormPanel().getStore().getModifiedRecords()[0];
      if(storeDataRecoder && modifiedRecord){
        if(storeDataRecoder.data.recordID === modifiedRecord.data.recordID){
          if(modifiedRecord.modified.hasOwnProperty("Cell_1")){
            if (modifiedRecord.modified.Cell_1 == storeDataRecoder.data.Cell_1){
              isCell_1modified = false;
            }else{
              isCell_1modified = true;
            }
          }
          if(modifiedRecord.modified.hasOwnProperty("Cell_2")){
            if(modifiedRecord.modified.Cell_2 === storeDataRecoder.data.Cell_2){
              isCell_2modified = false;
            }else{
              isCell_2modified = true;
            }
          }
          if(modifiedRecord.modified.hasOwnProperty("Cell_3")){
            if(modifiedRecord.modified.Cell_3 === storeDataRecoder.data.Cell_3){
              isCell_3modified = false;
            }else{
              isCell_3modified = true;
            }
          }
        }
      }

      if((isCell_1modified || isCell_3modified || isCell_2modified) === false){
        if(this.getParametersFormPanel().getStore().getModifiedRecords()){
          this.getParametersFormPanel().getStore().getModifiedRecords().length = 0;
        }
      }
      return (isCell_1modified || isCell_3modified || isCell_2modified);
    }
    ```