Twitter feed not available

New UDF, QueryConvertForjqGrid(), Released

A while back, I created a UDF that worked very similarly to queryConvertForGrid(), but was geared towards formatting the data to be used with jqGrid. Well, this afternoon, I finally got around to cleaning it up and posting it on CFLib.

If you never used or heard of jqGrid, it is a Plugin for jQuery that creates a grid, that is easily pagable and sortable (and can be 'skinned' with the jQueryUI ThemeRoller). I created queryConvertForjqGrid() because I wanted a quick, easy way to transform data from a query into data that can be read by jqGrid.

WARNING: In order for jqGrid to be able to use the data structure, you MUST add the following to your jqGrid configuration:

view plain print about
1datatype: 'json',
2jsonReader : {
3    repeatitems: false,
4    id: "{id}}"

Where {id} is the name of the column in the query that is the 'id' or that uniquely identifies the row in the result set.

You also need to make sure that whatever process is returning the data transforms it into a JSON string before sending it. If you are using a CFC to send the data back, it is as easy as adding 'returnFormat=json' to the query string. In jqGrid, you would set the 'URL' property in the configuration like this:

view plain print about

Use queryConvertForjqGrid() carefully as you will likely run into performance issues with very large data sets. I plan on adding support to handle formatting the data structure when the pagination is handled on the server.

Oh, and I can only say it will work on ColdFusion 9, if for no other reason than I have no other versions of ColdFusion installed on my development machine to test it on.


(Comment Moderation is enabled. Your comment will not appear until approved.)