-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExtjsGridTbar.vm
39 lines (39 loc) · 1.19 KB
/
ExtjsGridTbar.vm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Ext.define('${PROJECT_NAME}.view.grid.tbar.base.GridTbar', {
extend: 'Ext.toolbar.Toolbar',
requires: ['Ext.form.Label'],
xtype: 'gridtbar',
id: 'gridtbar',
items: [{
xtype: 'button',
text: 'Sync',
handler: function (thisObj) {
thisObj.findParentByType("grid").getStore().sync();
}
}, {
xtype: 'button',
text: 'Add',
handler: function (thisObj) {
let gridStore = thisObj.findParentByType("grid").getStore();
let storeModelClass = gridStore.getModel();
let objTmp = {};
objTmp[storeModelClass.idProperty] = '0';
let storeModel = new storeModelClass(objTmp);
gridStore.add(storeModel);
}
}, {
xtype: 'button',
text: 'Del',
handler: function (thisObj) {
let grid = thisObj.findParentByType("grid");
let gridStore = grid.getStore();
let selection = grid.getSelection();
if (selection.length === 1) {
gridStore.remove(selection[0])
gridStore.sync();
}
//grid.getStore().removeAt(rowIndex);
}
}
]
})
;