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.

TweetBacks
Comments
Andrew's Gravatar I'm afraid my question may seem foolish, but after googling; i can't find anyone selse having the same issue.

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
# Posted By Andrew | 8/19/09 10:42 PM
Steve 'Cutter' Blades's Gravatar @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.
# Posted By Steve 'Cutter' Blades | 8/19/09 10:54 PM
Andrew's Gravatar thanks for the fast response, that was actually the issue. I am not using Ext.Direct. The third example worked just fine.

thanks again

Andrew
# Posted By Andrew | 8/20/09 12:04 AM
jax's Gravatar In CFQueryReader.js there is this line (at 161):

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'...
# Posted By jax | 10/22/09 4:26 AM
jax's Gravatar So, in my opinion

- 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?
# Posted By jax | 10/22/09 4:55 AM
Steve 'Cutter' Blades's Gravatar You are right, that would fail. I've never seen a ColdFusion return that didn't uppercase the column names, even in manually built queries using QueryNew. However, I can see the point.

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...
# Posted By Steve 'Cutter' Blades | 10/22/09 10:25 AM
Azadi Saryev's Gravatar is there any particular reason why cfqueryreader would not work on Win Server 2008?

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?
# Posted By Azadi Saryev | 11/7/09 3:44 AM
Steve 'Cutter' Blades's Gravatar @Azadi,

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.
# Posted By Steve 'Cutter' Blades | 11/9/09 9:14 AM
Tony Walker's Gravatar I have exactly the same problem using Win Server 2008. I opened a ticket with EXT js but they could not figure anything out.
# Posted By Tony Walker | 11/13/09 6:07 PM
Steve 'Cutter' Blades's Gravatar @Tony,

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.
# Posted By Steve 'Cutter' Blades | 11/14/09 10:25 AM
Azadi Saryev's Gravatar regarding cfqueryreader on win server 2k8 problem i posted earlier:

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
# Posted By Azadi Saryev | 11/16/09 9:41 AM
Steve 'Cutter' Blades's Gravatar @Azadi,

Thanks Azadi. That is exactly the info I need to move forward with this. I'll see what I can dig up today.
# Posted By Steve 'Cutter' Blades | 11/16/09 9:44 AM
Steve 'Cutter' Blades's Gravatar The recent 3.0.3 update appeared to break CFQueryReader. Detailed analysis, refactor, and testing revealed that an internal method [getJsonAccessor()] of the Ext.data.JsonReader class had been changed [now createAccessor()]. Changes have been made to CFQueryReader to allow for either, dependent upon which is available.

Latest update is available on the CFQueryReader project page on RIAForge (http://cfqueryreader.riaforge.org).
# Posted By Steve 'Cutter' Blades | 11/17/09 1:23 PM
Tony Walker's Gravatar The CFQueryReader.js code at RIAForge is still the same as the old code
# Posted By Tony Walker | 11/17/09 3:25 PM
Steve 'Cutter' Blades's Gravatar I updated the SVN, but forgot to update the zip. I'll do that now. Thanks for the heads up.
# Posted By Steve 'Cutter' Blades | 11/17/09 3:46 PM
Tony Walker's Gravatar Excellent... everything works now. Many thanks to Azadi who helped me on Experts Exchange and especially to Cutter for creating such a great reader.

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'}
# Posted By Tony Walker | 11/17/09 5:02 PM
Steve 'Cutter' Blades's Gravatar Is the FIPS code the only thing you're returning? Or is it part of a query object?

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).
# Posted By Steve 'Cutter' Blades | 11/17/09 5:46 PM
James's Gravatar Hey Cutter, I got hooked on ExtJS when i attended your talk back at webmaniacs in 2008 and have your book. Awesome btw. Now i'm starting to play w/ 3.0 and the awesome new features like the Adobe Chart. Ran into a problem though and was wondering if you've encountered it before?

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.
# Posted By James | 12/14/09 11:34 AM
Steve 'Cutter' Blades's Gravatar @James,

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?
# Posted By Steve 'Cutter' Blades | 12/14/09 10:33 PM
Peter's Gravatar CFQueryReader is just what I needed. I've built my site around Spry and CF Ajax functionality, but there are some UI things I need that Ext has and I didn't want to toss my CFCs since they work for everything else.

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.
# Posted By Peter | 2/3/10 2:06 PM
Steve 'Cutter' Blades's Gravatar @Peter,

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.
# Posted By Steve 'Cutter' Blades | 2/5/10 1:44 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.9.3.006. Contact Blog Owner. Layout inspired by bluerobot.com., with some JQuery thrown in for fun.