2012-07-25 96 views
2

我需要在編輯功能中編輯網格單元值,而不是在validateedit函數中恢復(設置值爲編輯值之前)。Extjs4,如何在編輯功能中恢復編輯後的網格單元值?

"orderList": { 
    validateedit: function (plugin, edit) { 
     //validate... 
    }, 
    edit: function (plugin, edit) { 
     Ext.MessageBox.confirm('Confirm', 'Are you sure to change this order status?', function (btn) { 
     if (btn == 'yes') { 
      //update 
     } else { 
      // I want to rollback! 
      edit.cancel = true; 
      edit.record.data[edit.field] = edit.originalValue; //it does not work 
     } 
     }); 
    } 
} 

如何更改網格單元格值(編輯器)?

謝謝!

回答

4

怎麼樣reject method

"orderList": { 
    validateedit: function (plugin, edit) { 
     //validate... 
    }, 
    edit: function (plugin, edit) { 
     Ext.MessageBox.confirm('Confirm', 'Are you sure to change this order status?', function (btn) { 
      if (btn == 'yes') { 
       //update 
      } else { 
       edit.record.reject(); // this should revert all changes 
      } 
     }); 
    } 
} 

還要注意的是第二個參數的edit事件不包含cancel屬性(在名爲「編輯」的一個),那就是beforeedit事件的屬性。所以這條線edit.cancel = true不會爲你做任何事情。

我也很好奇爲什麼你沒有使用beforeedit事件,它似乎更適合這種事情 - 它爲什麼有這cancel屬性。

+0

非常感謝! – 2012-07-26 02:24:27

相關問題