Coldfusion and jQuery's Datatables

Coldfusion and jQuery's Datatables

Here is a quick guide on how you can use Coldfusion to populate jQuery's datatables

The first thing we need to sort out the the coldfusion code. The datatables function expects to be passed back an array in JSON format. Here we simply query our users table for matching users. We then loop over the dataset and save the required fields to a struct and then append that struct to an array.

At the end we add assign the array to the correct struct key (along with any other datatables details you want to pass back) and then  serialize the results

Next, the jquery

Everything you see above can be modified to your exact requirements. You can search deeper into the datatables code by going to their website. The part we are interested in is the 'aoColumns' attributes. This should map directly to the user array we created earlier.

comments powered by Disqus