4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-grid-property-Store-method-constructor'><span id='Ext-grid-property-Store'>/**
19 </span></span> * @class Ext.grid.property.Store
20 * @extends Ext.data.Store
21 * A custom {@link Ext.data.Store} for the {@link Ext.grid.property.Grid}. This class handles the mapping
22 * between the custom data source objects supported by the grid and the {@link Ext.grid.property.Property} format
23 * used by the {@link Ext.data.Store} base class.
25 * @param {Ext.grid.Grid} grid The grid this store will be bound to
26 * @param {Object} source The source data config object
28 Ext.define('Ext.grid.property.Store', {
30 extend: 'Ext.data.Store',
32 alternateClassName: 'Ext.grid.PropertyStore',
34 uses: ['Ext.data.reader.Reader', 'Ext.data.proxy.Proxy', 'Ext.data.ResultSet', 'Ext.grid.property.Property'],
36 constructor : function(grid, source){
43 model: Ext.grid.property.Property,
48 // Return a singleton, customized Proxy object which configures itself with a custom Reader
49 getProxy: function() {
51 Ext.grid.property.Store.prototype.proxy = Ext.create('Ext.data.proxy.Memory', {
52 model: Ext.grid.property.Property,
53 reader: this.getReader()
59 // Return a singleton, customized Reader object which reads Ext.grid.property.Property records from an object.
60 getReader: function() {
62 Ext.grid.property.Store.prototype.reader = Ext.create('Ext.data.reader.Reader', {
63 model: Ext.grid.property.Property,
65 buildExtractors: Ext.emptyFn,
67 read: function(dataObject) {
68 return this.readRecords(dataObject);
71 readRecords: function(dataObject) {
79 for (propName in dataObject) {
80 if (dataObject.hasOwnProperty(propName)) {
81 val = dataObject[propName];
82 if (this.isEditableValue(val)) {
83 result.records.push(new Ext.grid.property.Property({
90 result.total = result.count = result.records.length;
91 return Ext.create('Ext.data.ResultSet', result);
95 isEditableValue: function(val){
96 return Ext.isPrimitive(val) || Ext.isDate(val);
103 // protected - should only be called by the grid. Use grid.setSource instead.
104 setSource : function(dataObject) {
107 me.source = dataObject;
110 me.proxy.data = dataObject;
113 me.fireEvent('datachanged', me);
117 getProperty : function(row) {
118 return Ext.isNumber(row) ? this.getAt(row) : this.getById(row);
122 setValue : function(prop, value, create){
124 rec = me.getRec(prop);
127 rec.set('value', value);
128 me.source[prop] = value;
130 // only create if specified.
131 me.source[prop] = value;
132 rec = new Ext.grid.property.Property({name: prop, value: value}, prop);
138 remove : function(prop) {
139 var rec = this.getRec(prop);
142 delete this.source[prop];
147 getRec : function(prop) {
148 return this.getById(prop);
151 // protected - should only be called by the grid. Use grid.getSource instead.
152 getSource : function() {