|
@@ -194,8 +194,13 @@ export default function () {
|
|
me._setDataReal(value)
|
|
me._setDataReal(value)
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 添加行,并进入编辑状态
|
|
|
|
+ * @param record 新行的属性集
|
|
|
|
+ * @param editRowCol 要编辑的列序号
|
|
|
|
+ */
|
|
appendEditRow(record, editRowCol) {
|
|
appendEditRow(record, editRowCol) {
|
|
- const records = this.add(record)
|
|
|
|
|
|
+ const records = this.getStore().add(record)
|
|
const recNew = records[0]
|
|
const recNew = records[0]
|
|
this.setSelection(records)
|
|
this.setSelection(records)
|
|
|
|
|
|
@@ -206,8 +211,33 @@ export default function () {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 移除行
|
|
|
|
+ * @param record 如果记录传空,就是当前选中的行
|
|
|
|
+ */
|
|
|
|
+ removeEditRow(record) {
|
|
|
|
+ if (!record) {
|
|
|
|
+ record = this.refs.grid2.selection
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!record) {
|
|
|
|
+ msg('请选中要删除的行')
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.getStore().remove(record)
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ _transform(data) {
|
|
|
|
+ // 无论是 grid._setDataReal 还是 stores.gridInvokeBuild 都会走这个函数,设值前都可以改变表格值
|
|
|
|
+ _.forEach(data, row => {
|
|
|
|
+ row._origin = _.clone(row)
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
_setDataReal(value) {
|
|
_setDataReal(value) {
|
|
const me = this
|
|
const me = this
|
|
|
|
+ this._transform(value)
|
|
me.setStore(new Ext.data.Store({
|
|
me.setStore(new Ext.data.Store({
|
|
fields: getFileds(this),
|
|
fields: getFileds(this),
|
|
data: value
|
|
data: value
|