1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-grid.property.Store-method-constructor'><span id='Ext-grid.property.Store'>/**
2 </span></span> * @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){
24 model: Ext.grid.property.Property,
25 proxy: this.getProxy()
29 // Return a singleton, customized Proxy object which configures itself with a custom Reader
30 getProxy: function() {
32 Ext.grid.property.Store.prototype.proxy = Ext.create('Ext.data.proxy.Memory', {
33 model: Ext.grid.property.Property,
34 reader: this.getReader()
40 // Return a singleton, customized Reader object which reads Ext.grid.property.Property records from an object.
41 getReader: function() {
43 Ext.grid.property.Store.prototype.reader = Ext.create('Ext.data.reader.Reader', {
44 model: Ext.grid.property.Property,
46 buildExtractors: Ext.emptyFn,
48 read: function(dataObject) {
49 return this.readRecords(dataObject);
52 readRecords: function(dataObject) {
59 for (var propName in dataObject) {
60 val = dataObject[propName];
61 if (dataObject.hasOwnProperty(propName) && this.isEditableValue(val)) {
62 result.records.push(new Ext.grid.property.Property({
68 result.total = result.count = result.records.length;
69 return Ext.create('Ext.data.ResultSet', result);
73 isEditableValue: function(val){
74 return Ext.isPrimitive(val) || Ext.isDate(val);
81 // protected - should only be called by the grid. Use grid.setSource instead.
82 setSource : function(dataObject) {
85 me.source = dataObject;
88 me.proxy.data = dataObject;
91 me.fireEvent('datachanged', me);
95 getProperty : function(row) {
96 return Ext.isNumber(row) ? this.store.getAt(row) : this.store.getById(row);
100 setValue : function(prop, value, create){
101 var r = this.getRec(prop);
103 r.set('value', value);
104 this.source[prop] = value;
106 // only create if specified.
107 this.source[prop] = value;
108 r = new Ext.grid.property.Property({name: prop, value: value}, prop);
114 remove : function(prop) {
115 var r = this.getRec(prop);
117 this.store.remove(r);
118 delete this.source[prop];
123 getRec : function(prop) {
124 return this.store.getById(prop);
127 // protected - should only be called by the grid. Use grid.getSource instead.
128 getSource : function() {
131 });</pre></pre></body></html>