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

Posted on 2012-08-27
Last Modified: 2012-09-04
I also posted this as a discussion on the datatables website.

Using the following code:
 oTable = $('').dataTable({
 "bProcessing": true,
 "bServerSide": true,
 "bStateSave": false,

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.
Question by:HyperBPP
    1 Comment
    LVL 15

    Accepted Solution

    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

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question ( on how to make a page show some balloons animate up a page…
    PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now