WeaverTablePlugins_wev8.js
1.75 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
Ext.namespace('Ext.ux.plugins');
Ext.ux.plugins.CheckBoxMemory = Ext.extend(Object,
{
constructor: function(config)
{
//if (!config)
// config = {};
this.hdID = config.hdID;
this.prefix = 'id_';
this.items = {};
this.idProperty = config.idProperty || 'id';
},
init: function(grid)
{
this.grid = grid;
this.view = grid.getView()
this.store = null;
this.sm = grid.getSelectionModel();
this.sm.on('rowselect', this.onSelect, this);
this.sm.on('rowdeselect', this.onDeselect, this);
this.view.on('refresh', this.reConfigure, this);
},
reConfigure: function() {
this.store = this.grid.getStore();
var hd = Ext.fly(Ext.getDom(this.hdID).parentNode)
hd.removeClass('x-grid3-hd-checker-on');
this.store.on('clear', this.onClear, this);
this.store.on('datachanged', this.restoreState, this);
},
onSelect: function(sm, idx, rec)
{
this.items[this.getId(rec)] = true;
},
onDeselect: function(sm, idx, rec)
{
delete this.items[this.getId(rec)];
},
restoreState: function()
{
if (this.store != null) {
var i = 0;
var sel = [];
this.store.each(function(rec)
{
var id = this.getId(rec);
if (this.items[id] === true)
sel.push(i);
++i;
}, this);
if (sel.length > 0)
this.sm.selectRows(sel);
}
},
onClear: function()
{
var sel = [];
this.items = {};
},
getId: function(rec)
{
return rec.id;
},
getSelection:function(){
var selecton='';
for(var key in this.items){
selecton+=key+','
}
return selecton;
}
});