the singularity of being and nothingness
Posts tagged ExtJS

Ext to ColdFusion…Nice!
Feb 21st
So I know a lot of the posts I’ve been writing recently have been about stuff that’s been around a while–Ext helper functions, CFScript, etc. Nonetheless, I post them because some of the answers to questions I’ve found in developing solutions have been less-than-easy to find, so perhaps repeating some of the same things again will help Google find it a bit easier for someone else someday.
On with redundancy!
Obviously, JSON-related technologies have been around for a while, and with ColdFusion 8, a lot of native JSON handling was added for the creation of some sweet AJAX-y goodness. While I’ve dabbled with these, I’ve never really had a need for them…until now.
I recently developed a remote CFC function that required about 12 different arguments. On the client side, I also developed a quick EXT Ajax.request() method to pass these arguments into the CFC function.
Now with Ext, it’s incredibly simple to pass arguments to server-side functions, as this example illustrates:
Ext.Ajax.request({ url: 'com/functions.cfc', success: successMethod, failure: errorMethod, headers: {"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"}, params: {method:'setupLife',argument1:arg1,argument2:arg2} });
I like this alot, because it allows me to treat each argument as its own “thing,” rather than stringing together a bunch of “&argument1=arg1” in the query string.
But what if More >

30 Seconds with Ext
Feb 11th
Ok, so this is not earth-shattering, but I came across a pretty cool feature in Ext's DomHelper class the other day.
But first, a little context. Don't you just HATE creating new HTML elements with JavaScript? If you go the route of explicitly pasting them together, your code ends up looking like spaghetti…and I hope you're good at tracking down escaping errors 🙂
And what about wrangling with createELement, appendChild, and the ilk with their corresponding unpredictable behavior across browsers?
It's a gigantic pain in the butt, but as I found out recently, Ext makes it SUPER simple. Using the DomHelper class, you can easily leverage Ext to confidently generate any number of elements without having to worry about escaping characters or remembering the nuances of creating elements for each browser.
Let's say I just want to make a new table:
Ext.DomHelper.append('cart-details', {tag:'table', id:'detail-table'});
In this super simple example, I'm adding a new table element to an existing div with an id of "cart-details." To add the table, I simply invoke the append() method from the DomHelper, and 40 characters later I'm all set.
But what is even cooler is that the DomHelper class allows you to create NESTED elements as well! Check this out:
Ext.DomHelper.append('detail-table', { tag: More >

Converting ColdFusion Queries for Ext
Jan 21st
At my new job, we use Ext fairly regularly to get some pretty cool AJAXiness up in the mix of things. To familiarize myself with Ext (I’ve not really used it until now), I recently downloaded the newest version and have been playing around with it quite a bit.
One of the elements I like quite a bit is the data grid. Like most other things, Ext makes it pretty simple to pull off a slick sortable, pageable data grid with very little work.
Of course, given that I use ColdFusion alot, I decided to hook up a grid to a remote CFC call. While the call itself is easy enough to do, there is one issue: the JSON that CF returns is in a format that Ext cannot quite understand.
Now there are a bunch of pre-built converters out there, some more robust than others (and a few I couldn’t quite get to work).
So in the spirit of trying to figure it out for myself, I wrote up a simple function in ColdFusion that will take a regular query and convert it into happy JSON that Ext can deal with.
First, here’s our function to create our generic query:
<cffunction name="getPosts" access="remote" returnformat="json" output="false" hint="Gets list/detail More >