UnitsManager.js
1.09 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
Ext.define('treps.controller.Vectors.UnitsManager', {
singleton : true,
constructor: function() {
},
loadUnitsStore: function(onAfterLoad) {
var me = this;
var store = this.getUnitsStore();
/* Create a local store
var myStore = Ext.create('Ext.data.Store',{
fields:['Id','fullname',''],
data:[
{Id:0,Name:'Yes'},
{Id:1,Name:'No'},
{Id:2,Name:'Maybe'}
]
});
*/
//if store exists, empty it
if (store != null)
store.removeAll();
else
store = Ext.create('treps.store.Units');
console.log('****** loading unitManager store ');
store.load(
{
scope: me,
callback: function(records, operation, success)
{
if (!success)
{
treps.Messages.showError("Cannot get units list");
return;
}
if (onAfterLoad != null)
onAfterLoad.call(me,store);
}
});
},
getUnitsStore : function()
{
return Ext.getStore('UnitsStore');
},
getFirstUnitId : function()
{
var store = this.getUnitsStore();
if ((store != null) && (store.count() > 0))
return store.getAt(0).get("id");
return "";
}
});