?
Solved

Jquery Datatables 1.9 with sAjaxSource columns not auto width to column contents.

Posted on 2012-08-27
1
Medium Priority
?
2,047 Views
Last Modified: 2012-09-04
I also posted this as a discussion on the datatables website.

Using the following code:
 
$(document).ready(function(){
 oTable = $('###URL.name#').dataTable({
 "bProcessing": true,
 "bServerSide": true,
 "bStateSave": false,
 "bAutoWidth:":true,
 "sAjaxSource":"#application.settings.absoluteURL#Framework/Generics/DB/CFM/dataTableAJAXForm.cfm?name=#url.name#"


 });
 
WHen I apply this the columns all come with even width. If i do not use sAjaxSource and simply put all the table contents on the page the column widths vary with the width of the data. Is there a way to do this with sAjaxSource without explicitly defining each column swidth? The table is used in a generic "template" page that will have a wide variety of columns. I dynamically print the column headers and footers to the page with a function (using ColdFusion 9 btw).
 
Thanks! Datatables is rad btw.
0
Comment
Question by:HyperBPP
1 Comment
 
LVL 16

Accepted Solution

by:
Gurpreet Singh Randhawa earned 2000 total points
ID: 38339815
You need to use the swidth if you are using the AAjaxsource as the data you are getting is in JSON format and then you have a width of 100%, now if you have 5 columns, you have divide your width as such so it comes to 100%

for a complete working example you can visit this Blog Entry

http://www.mccran.co.uk/index.cfm/2010/4/29/JQuery-Datatables-plugin-example-using-a-server-side-data-request-coldfusion

http://www.cutterscrossing.com/index.cfm/2011/2/7/Using-The-DataTables-JQuery-Plugin
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month15 days, 6 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question