]> git.proxmox.com Git - proxmox-widget-toolkit.git/blame - data/ObjectStore.js
fixup: rename returnCompleteRecord to getRecord
[proxmox-widget-toolkit.git] / data / ObjectStore.js
CommitLineData
0bb29d35
DM
1/* This store encapsulates data items which are organized as an Array of key-values Objects
2 * ie data[0] contains something like {key: "keyboard", value: "da"}
3*
4* Designed to work with the KeyValue model and the JsonObject data reader
5*/
6Ext.define('Proxmox.data.ObjectStore', {
7 extend: 'Proxmox.data.UpdateStore',
8
73b0150c 9 getRecord: function() {
59db7031
DC
10 var me = this;
11 var record = Ext.create('Ext.data.Model');
12 me.getData().each(function(item) {
13 record.set(item.data.key, item.data.value);
14 });
15 record.commit(true);
16 return record;
17 },
18
0bb29d35
DM
19 constructor: function(config) {
20 var me = this;
21
22 config = config || {};
23
24 if (!config.storeid) {
25 config.storeid = 'proxmox-store-' + (++Ext.idSeed);
26 }
27
28 Ext.applyIf(config, {
29 model: 'KeyValue',
30 proxy: {
31 type: 'proxmox',
32 url: config.url,
33 extraParams: config.extraParams,
34 reader: {
35 type: 'jsonobject',
36 rows: config.rows,
37 readArray: config.readArray,
38 rootProperty: config.root || 'data'
39 }
40 }
41 });
42
43 me.callParent([config]);
44 }
45});