CFQueryReader v1.2 - Critical Update Supporting ExtJS 3.x
I have updated CFQueryReader, addressing issues that had arisen with new builds of ExtJs 3.x. This new build should cover sporadic issues with loading a new Ext.data.Store. There is also a simple example of using Aaron Conran's DirectCFM Ext.Direct ColdFusion API stack.
The CFQueryReader Example Site has been updated as well. You can update CFQueryReader from RIAForge.


I am playing with EXT3 for the first time and somewhat new to it. I am trying to proxy my CFCs and pull the results into a dragable portal typy within grouptabs.js
So, I thought i would start by playing with this CFQueryReader
unfortunately i get an error "com is not defined" and that points to line 47 of my code which is:
var provider = Ext.Direct.addProvider(com.cc.APIDesc);
I copied that from the included test.js sample.
any help would be appreciated
Andrew
Are you using Ext.Direct? That line is only if you're using Ext.Direct, and have included the DirectCFM stuff. Best guess is that you only require the stuff from examples 2 and 3.
thanks again
Andrew
fi[b].mapArrLoc = cols.indexOf(Ext.util.Format.uppercase(fMap));
This means, that cfqueryreader *always* searches for capitalised column names in the receiving JSON string, even when they are not..
so a Json string like :
{"COLUMNS":["ID","afield"],"DATA":[[1,"1"]]}
will fail to load data because CFQueryReader will look for 'AFIELD' instead of 'afield'...
- CFqueryReader should never alter column names it received in it's json string (uppercasing = altering).
- or then at least generate a warning that it can't find the capitilized (read: altered) column name..
What do you think?
The issue at hand is that JavaScript is case sensitive, whereas ColdFusion is not. We have to convert the return, in some fashion, to standardize the content prior to processing. For this, I would uppercase the values of the COLUMNS array (around line 140) prior to processing:
<code>
var cols = this.getQueryRoot(o).COLUMNS;
for (var i = 0;i < cols.length;i++){
cols[i] = cols[i].toUpperCase();
}
</code>
Give that a try, and see if it resolves the issue. Let me know if that works out...
it works on my dev machine running win xp, but on win server 2008 the grid is drawn with no data, even though the data is returned (i see it in firebug, and it IS a valid json object).
furthermore, switching to cfjsonreader makes the data in the grid appear on 2k8 server...
any ideas?
Sorry, I just got back from vacation. Use the "Contact Blog Owner" link, at the bottom of the page, and send me a copy of your config, as well as a copy of the JSON return you are getting (Firebug will show that), and I'll see if I can't help you figure it out.
Send me the details through the "Contact Blog Owner" link at the bottom of the page, and I'll see what I can do to help out.
it turned out to be an issue with using extjs 3.0.3 (current latest version).
cfqueryreader just does not work with it (yet, i presume) no matter what OS.
3.0.0 works fine, but 3.0.3 fails to load any data into the grid.
Azadi
Thanks Azadi. That is exactly the info I need to move forward with this. I'll see what I can dig up today.
Latest update is available on the CFQueryReader project page on RIAForge (http://cfqueryreader.riaforge.org).
Cutter... since you are a ColdFusion guy would you have any idea why a column that is defined in my 2008 sql server database as a varchar(5) and contains county FIPS codes would come through as numeric? If I do a cfdump of the query in the cfc the value will show as 06017 but when I see it in the console it is 6017.0 numeric. Here is the record model mapping:
{name:'FIPS',mapping:'FIPS',type:'string'}
By itself, you may have to use a response.text.toString() type of scenario, prior to process. You may also use a returnFormat argument of 'plain' instead of JSON, as CF will convert the 'string' number to a number in JSON returns (known bug there).
When using cfqueryreader to pull a recordset to feed a series to the chart component, my series fail to take up the whole width of the chart. If there are 2 series it uses half of the x width, if there are 3, it uses 1/3 and so on. Almost as if the chart is expecting to use the total count of the data points. I changed the data reader to the old school cfjsonreader that I used to use and it works just fine. Any ideas on what's going on? Could it possibly be a bug?
Again, thanks for getting me hooked on this awesome framework, and all of your contributions.
I don't have a ton of experience with the charting components, but if you can flash me some code, and a sampling of the json return you're getting from CF, I'll take a look and see what I can come up with for you. Just use the 'Contact Blog Owner' link at the bottom of my blog. Also, are you using the latest update in the download on RIAForge?
I use two ways to produce JSON from CF:
1) Return a query object and specify returnFormat="json" in the function definition
2) Return a string from SerializeJSON(qry, false) and specify returnFormat="plain" in the function definition
Most of my coding uses the last one, since I can use a custom JSON prefix scheme (I store a prefix in the Client scope that gets changed with every page request and check it on the client when data arrives).
Spry will consume the last one also, but you need to use SerializeJSON(qry, true) to make it work. This return
comes in the following format:
{"ROWCOUNT":8,"COLUMNS":["F1","F2"],"DATA":{"F1":[180,181,182,183,184,185,186,187],"F2":["Air Nigeria","Chrome Air Service","EAS Airlines","Falcon Airlines","Merchant Express Aviation","Nexus Aviation","Okada Airlines","RiteTime Aviation"]}}
As you can see it's very similar to the output from the CF QueryConvertForGrid() method, so i should be able to enhance it to accommodate it.
Again, thanks for a nice piece of work and for giving me the starting point I needed.
Yeah, I will ofter have my method return a struct as the response object, typically with two keys: success [true] and query (in the event of a successful transaction, or success [false] and message (in the event of a failed transaction. I then use returnFormat="json" in the arguments of the ajax request. ColdFusion will automatically serialize the struct on request, and I can then use the root attribute of the reader configuration to denote that 'query' is the actual object to be read in.
I like your CLIENT scope auto-morphing prefix though, from a security standpoint. The only downside is that the server-side method can then only be used for ajax requests, and I try to make reusable functions that I can call client or server-side.