Last active
March 9, 2022 17:48
-
-
Save flexdevguy/8e7e8b9c6bdfd7938cddb5c7f39ecc6c to your computer and use it in GitHub Desktop.
Extjs Key value json reader for store
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @class com.flexdevguy.data.reader.KeyValue | |
| * @extends Ext.data.reader.Json | |
| * Key value json reader for store | |
| */ | |
| Ext.define('com.flexdevguy.data.reader.KeyValue', { | |
| extend: 'Ext.data.reader.Json', | |
| alias : 'reader.keyvalue', | |
| getRoot: function(data) { | |
| if (this.rootAccessor) { | |
| data = this.rootAccessor.call(this, data); | |
| } | |
| var values = [], | |
| key; | |
| for (key in data) { | |
| values.push({ | |
| key: key, | |
| value: data[key] | |
| }); | |
| } | |
| return values; | |
| } | |
| }); | |
| var store = Ext.create('Ext.data.Store', { | |
| fields: ['key', 'value'], | |
| autoLoad: true, | |
| proxy: { | |
| type: 'ajax', | |
| url: 'xyz.json', | |
| reader: { | |
| type: 'keyvalue', | |
| rootProperty: 'jsonroot' | |
| } | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment