Skip to content
Browse files

Fix for indexOf, when working with legacy browsers. Thanks to Jim Par…

…tin for the heads up.
  • Loading branch information...
1 parent 056c14c commit dc0a48f28df0640e56f437212fffa0f9b21f7e97 @cutterbl committed May 18, 2012
View
1 .gitignore
@@ -1,3 +1,4 @@
/.project
/settings.xml
/GA_code_for_examples.txt
+/*.tmp*
View
4 css/default.css
@@ -58,11 +58,11 @@ pre {
padding: 10px 20px;
}
-.x-panel-body, .x-panel-body-noheader {
+/*.x-panel-body, .x-panel-body-noheader {
padding: 5px;
background-color: #E6E8E8;
color: #000;
-}
+}*/
.demoGrids .x-grid { margin: 0 auto; }
View
4 index-4.html
@@ -9,14 +9,14 @@
<link rel="stylesheet" type="text/css" href="/css/default.css" />
<link rel="shortcut icon" href="/favicon_32x32.ico" />
<script type="text/javascript" src="/js/extjs-4.1.0/ext-all.js"></script>
- <script type="text/javascript" src="/js/custom/CFQueryReader-ExtJS4-2.1.min.js"></script>
+ <script type="text/javascript" src="/js/custom/CFQueryReader-ExtJS4-2.2.min.js"></script>
<script language="javascript" type="text/javascript" src="/servicebus/Api.cfm"></script>
<script type="text/javascript" src="/js/custom/test-extjs_4.js"></script>
</head>
<body>
<div id="content">
<ul>
- <li><a href="/js/custom/CFQueryReader-ExtJS4-2.1.js" target="_blank">CFQueryReader.js</a> - v2.1 for Ext JS 4.1.0</li>
+ <li><a href="/js/custom/CFQueryReader-ExtJS4-2.2.js" target="_blank">CFQueryReader.js</a> - v2.1 for Ext JS 4.1.0</li>
<li><a href="/js/custom/test-extjs_4.js" target="_blank">test-extjs_4.js</a> - script for this page</li>
</ul><br />
<p>This is a Demo for CFQueryReader with <a href="/js/extjs-4.1.0/docs/" target="_blank">ExtJS 4.1.0</a>. ExtJS 4 is the latest version of ExtJS, and is a complete rewrite of the entire framework. With that comes an entirely new CFQueryReader, that conforms to Ext's new class model. There are three stores defined in the script:</p>
View
4 index-5.html
@@ -9,14 +9,14 @@
<link rel="stylesheet" type="text/css" href="/css/default.css" />
<link rel="shortcut icon" href="/favicon_32x32.ico" />
<script type="text/javascript" src="/js/extjs-4.1.0/ext-all.js"></script>
- <script type="text/javascript" src="/js/custom/CFQueryReader-ExtJS4-2.1.min.js"></script>
+ <script type="text/javascript" src="/js/custom/CFQueryReader-ExtJS4-2.2.min.js"></script>
<script language="javascript" type="text/javascript" src="/servicebus/Api.cfm"></script>
<script type="text/javascript" src="/js/custom/test-extjs_4_pt2.js"></script>
</head>
<body>
<div id="content">
<ul>
- <li><a href="/js/custom/CFQueryReader-ExtJS4-2.1.js" target="_blank">CFQueryReader.js</a> - v2.1 for Ext JS 4.1.0</li>
+ <li><a href="/js/custom/CFQueryReader-ExtJS4-2.2.js" target="_blank">CFQueryReader.js</a> - v2.1 for Ext JS 4.1.0</li>
<li><a href="/js/custom/test-extjs_4_pt2.js" target="_blank">test-extjs_4_pt2.js</a> - script for this page</li>
</ul><br />
<p>This is a Demo for CFQueryReader with <a href="/js/extjs-4.1.0/docs/" target="_blank">ExtJS 4.1.0</a>. ExtJS 4 is the latest version of ExtJS, and is a complete rewrite of the entire framework. With that comes an entirely new CFQueryReader, that conforms to Ext's new class model. There is a single store defined in the script:</p>
View
1 js/custom/CFQueryReader-ExtJS4-2.1.min.js
@@ -1 +0,0 @@
-Ext.define("ColdFusion.data.reader.CFQueryReader",{extend:"Ext.data.reader.Array",alternateClassName:"ColdFusion.data.CFQueryReader",alias:"reader.cfquery",query:"QUERY",totalProperty:"TOTALROWCOUNT",readRecords:function(a){var b=this,c,d,e=true;if(a.DATA&&a.COLUMNS){var f=new Object;f["QUERY"]=Ext.Object.merge({},a);a=f}var g=this.model.prototype.fields.items;if(a.metaData){b.onMetaChange(a.metaData);if(a.metaData.fields)e=false}if(e){c=b.getQuery(a);try{if(Ext.isObject(c)){if(c.DATA&&Ext.isArray(c.DATA)&&c.COLUMNS&&Ext.isArray(c.COLUMNS)){for(var h=0;h<=c.COLUMNS;h++){c.COLUMNS[h]=c.COLUMNS[h].toUpperCase()}for(var h=0;h<g.length;h++){var i=c.COLUMNS.indexOf(g[h].name.toUpperCase());if(i>=0){g[h].mapping=c.COLUMNS.indexOf(g[h].name.toUpperCase())}}if(b.model){b.model.setFields(g,b.idProperty);b.setModel(b.model,true)}}else{throw"The 'query' is not properly mapped to the response."}}else{throw"A 'query' is not defined in the server output."}}catch(j){d=new Ext.data.ResultSet({total:0,count:0,records:[],success:false,message:j});this.fireEvent("exception",this,response,d);Ext.Logger.warn(j);return d}}this.jsonData=a;return this.callParent([a])},buildExtractors:function(){var a=this;a.callParent(arguments);if(a.query&&!a.root){a.root=a.query}if(a.root){var b=a.root.split(".");if(b[b.length-1]==="DATA"){b.pop()}b=b.join(".");a.query=b;a.getQuery=a.createAccessor(a.query);a.root=b.length?b+".DATA":"DATA";a.getRoot=a.createAccessor(a.root)}else{a.getRoot=function(a){return a}}}})
View
7 js/custom/CFQueryReader-ExtJS4-2.1.js → js/custom/CFQueryReader-ExtJS4-2.2.js
@@ -1,6 +1,7 @@
/**
* @author Steve 'Cutter' Blades
* @class ColdFusion.data.reader.CFQueryReader
+ * @version 2.2 [05.17.2012]
*
* <p>The CFQueryReader Reader is used by a Proxy to read a ColdFusion server response that is sent back in JSON format. This usually
* happens as a result of loading a Store - for example we might create something like this:</p>
@@ -222,9 +223,9 @@ Ext.define('ColdFusion.data.reader.CFQueryReader',{
}
// Map the columns. Fields might not map to a column in the response
for (var i = 0; i < fields.length; i++) {
- var pos = obj.COLUMNS.indexOf(fields[i].name.toUpperCase());
+ var pos = Ext.Array.indexOf(obj.COLUMNS, fields[i].name.toUpperCase());
if(pos >= 0){
- fields[i].mapping = obj.COLUMNS.indexOf(fields[i].name.toUpperCase());
+ fields[i].mapping = Ext.Array.indexOf(obj.COLUMNS, fields[i].name.toUpperCase());
}
}
// Put the changes back in the model
@@ -247,7 +248,7 @@ Ext.define('ColdFusion.data.reader.CFQueryReader',{
message: err
});
- this.fireEvent('exception', this, response, error);
+ this.fireEvent('exception', this, data, error);
Ext.Logger.warn(err);
View
1 js/custom/CFQueryReader-ExtJS4-2.2.min.js
@@ -0,0 +1 @@
+Ext.define("ColdFusion.data.reader.CFQueryReader",{extend:"Ext.data.reader.Array",alternateClassName:"ColdFusion.data.CFQueryReader",alias:"reader.cfquery",query:"QUERY",totalProperty:"TOTALROWCOUNT",readRecords:function(a){var b=this,c,d,e=true;if(a.DATA&&a.COLUMNS){var f=new Object;f["QUERY"]=Ext.Object.merge({},a);a=f}var g=this.model.prototype.fields.items;if(a.metaData){b.onMetaChange(a.metaData);if(a.metaData.fields)e=false}if(e){c=b.getQuery(a);try{if(Ext.isObject(c)){if(c.DATA&&Ext.isArray(c.DATA)&&c.COLUMNS&&Ext.isArray(c.COLUMNS)){for(var h=0;h<=c.COLUMNS;h++){c.COLUMNS[h]=c.COLUMNS[h].toUpperCase()}for(var h=0;h<g.length;h++){var i=Ext.Array.indexOf(c.COLUMNS,g[h].name.toUpperCase());if(i>=0){g[h].mapping=Ext.Array.indexOf(c.COLUMNS,g[h].name.toUpperCase())}}if(b.model){b.model.setFields(g,b.idProperty);b.setModel(b.model,true)}}else{throw"The 'query' is not properly mapped to the response."}}else{throw"A 'query' is not defined in the server output."}}catch(j){d=new Ext.data.ResultSet({total:0,count:0,records:[],success:false,message:j});this.fireEvent("exception",this,a,d);Ext.Logger.warn(j);return d}}this.jsonData=a;return this.callParent([a])},buildExtractors:function(){var a=this;a.callParent(arguments);if(a.query&&!a.root){a.root=a.query}if(a.root){var b=a.root.split(".");if(b[b.length-1]==="DATA"){b.pop()}b=b.join(".");a.query=b;a.getQuery=a.createAccessor(a.query);a.root=b.length?b+".DATA":"DATA";a.getRoot=a.createAccessor(a.root)}else{a.getRoot=function(a){return a}}}})
View
9 js/custom/test-extjs_4.js
@@ -60,7 +60,14 @@ Ext.onReady(function(){
Ext.create('Ext.grid.Panel', Ext.Object.merge({}, gridPanelBase, {
title: 'Testing: GetAllStandard (Basic CF Query object)',
store: Ext.getStore('entryStore'),
- renderTo: 'demo1'
+ renderTo: 'demo1',
+ columns: [
+ {header: 'ID', dataIndex: 'id', hidden: true},
+ {header: 'Title', dataIndex: 'title', flex: 6},
+ {header: 'Posted', dataIndex: 'posted', flex: 2},
+ {header: 'Views', dataIndex: 'views', align: 'right', flex: 2}
+ ],
+ scroll: 'vertical'
})
);

0 comments on commit dc0a48f

Please sign in to comment.
Something went wrong with that request. Please try again.