2 * @class Ext.grid.property.Store
3 * @extends Ext.data.Store
4 * A custom {@link Ext.data.Store} for the {@link Ext.grid.property.Grid}. This class handles the mapping
5 * between the custom data source objects supported by the grid and the {@link Ext.grid.property.Property} format
6 * used by the {@link Ext.data.Store} base class.
8 * @param {Ext.grid.Grid} grid The grid this store will be bound to
9 * @param {Object} source The source data config object
11 Ext.define('Ext.grid.property.Store', {
13 extend: 'Ext.data.Store',
15 alternateClassName: 'Ext.grid.PropertyStore',
17 uses: ['Ext.data.reader.Reader', 'Ext.data.proxy.Proxy', 'Ext.data.ResultSet', 'Ext.grid.property.Property'],
19 constructor : function(grid, source){
26 model: Ext.grid.property.Property,
31 // Return a singleton, customized Proxy object which configures itself with a custom Reader
32 getProxy: function() {
34 Ext.grid.property.Store.prototype.proxy = Ext.create('Ext.data.proxy.Memory', {
35 model: Ext.grid.property.Property,
36 reader: this.getReader()
42 // Return a singleton, customized Reader object which reads Ext.grid.property.Property records from an object.
43 getReader: function() {
45 Ext.grid.property.Store.prototype.reader = Ext.create('Ext.data.reader.Reader', {
46 model: Ext.grid.property.Property,
48 buildExtractors: Ext.emptyFn,
50 read: function(dataObject) {
51 return this.readRecords(dataObject);
54 readRecords: function(dataObject) {
62 for (propName in dataObject) {
63 if (dataObject.hasOwnProperty(propName)) {
64 val = dataObject[propName];
65 if (this.isEditableValue(val)) {
66 result.records.push(new Ext.grid.property.Property({
73 result.total = result.count = result.records.length;
74 return Ext.create('Ext.data.ResultSet', result);
78 isEditableValue: function(val){
79 return Ext.isPrimitive(val) || Ext.isDate(val);
86 // protected - should only be called by the grid. Use grid.setSource instead.
87 setSource : function(dataObject) {
90 me.source = dataObject;
93 me.proxy.data = dataObject;
96 me.fireEvent('datachanged', me);
100 getProperty : function(row) {
101 return Ext.isNumber(row) ? this.getAt(row) : this.getById(row);
105 setValue : function(prop, value, create){
107 rec = me.getRec(prop);
110 rec.set('value', value);
111 me.source[prop] = value;
113 // only create if specified.
114 me.source[prop] = value;
115 rec = new Ext.grid.property.Property({name: prop, value: value}, prop);
121 remove : function(prop) {
122 var rec = this.getRec(prop);
125 delete this.source[prop];
130 getRec : function(prop) {
131 return this.getById(prop);
134 // protected - should only be called by the grid. Use grid.getSource instead.
135 getSource : function() {