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'>/**
19 </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 Ext.define('Ext.grid.property.Store', {
27 extend: 'Ext.data.Store',
29 alternateClassName: 'Ext.grid.PropertyStore',
31 uses: ['Ext.data.reader.Reader', 'Ext.data.proxy.Proxy', 'Ext.data.ResultSet', 'Ext.grid.property.Property'],
33 <span id='Ext-grid-property-Store-method-constructor'> /**
34 </span> * Creates new property store.
35 * @param {Ext.grid.Grid} grid The grid this store will be bound to
36 * @param {Object} source The source data config object
38 constructor : function(grid, source){
45 model: Ext.grid.property.Property,
50 // Return a singleton, customized Proxy object which configures itself with a custom Reader
51 getProxy: function() {
53 Ext.grid.property.Store.prototype.proxy = Ext.create('Ext.data.proxy.Memory', {
54 model: Ext.grid.property.Property,
55 reader: this.getReader()
61 // Return a singleton, customized Reader object which reads Ext.grid.property.Property records from an object.
62 getReader: function() {
64 Ext.grid.property.Store.prototype.reader = Ext.create('Ext.data.reader.Reader', {
65 model: Ext.grid.property.Property,
67 buildExtractors: Ext.emptyFn,
69 read: function(dataObject) {
70 return this.readRecords(dataObject);
73 readRecords: function(dataObject) {
81 for (propName in dataObject) {
82 if (dataObject.hasOwnProperty(propName)) {
83 val = dataObject[propName];
84 if (this.isEditableValue(val)) {
85 result.records.push(new Ext.grid.property.Property({
92 result.total = result.count = result.records.length;
93 return Ext.create('Ext.data.ResultSet', result);
97 isEditableValue: function(val){
98 return Ext.isPrimitive(val) || Ext.isDate(val);
105 // protected - should only be called by the grid. Use grid.setSource instead.
106 setSource : function(dataObject) {
109 me.source = dataObject;
112 me.proxy.data = dataObject;
115 me.fireEvent('datachanged', me);
119 getProperty : function(row) {
120 return Ext.isNumber(row) ? this.getAt(row) : this.getById(row);
124 setValue : function(prop, value, create){
126 rec = me.getRec(prop);
129 rec.set('value', value);
130 me.source[prop] = value;
132 // only create if specified.
133 me.source[prop] = value;
134 rec = new Ext.grid.property.Property({name: prop, value: value}, prop);
140 remove : function(prop) {
141 var rec = this.getRec(prop);
143 this.callParent([rec]);
144 delete this.source[prop];
149 getRec : function(prop) {
150 return this.getById(prop);
153 // protected - should only be called by the grid. Use grid.getSource instead.
154 getSource : function() {