Ajax source and aaData initialisation parameter - width of columns different after second call

Ajax source and aaData initialisation parameter - width of columns different after second call

earacheflearachefl Posts: 11Questions: 0Answers: 0
edited November 2011 in General
As the title says, I'm using an Ajax call to get new data for my tables and using the aaData initialization parameter. The calls all work correctly and repopulate the tables with the correct data. The problem that I have is that although the first table is drawn correctly, all subsequent calls don't auto-size the column widths to fill the entire width of the table - instead, the columns are only as wide as their data.

I'm calling DataTables like so:
[code]
$(document).ready(function(){
$('#applyFilter').click(function(){
//set up vars for ajax options and aoColumns
$.get('myAjaxsource', options, function(response){
$('#grid-container').dataTable({
'aaData': response.AADATA,
"aoColumns": aoColumns,
"bJQueryUI": true,
"bDestroy": true
});
});
});
}
[/code]
Note: the aoColumns object does not include explicit widths. Also, I've tried removing the bJQueryUI parameter.

Replies

  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin
    Have you got #grid-container {width: 100%} in your CSS? It should be that when the table is destroyed the width is set back to what it originally was (but as a pixel value rather than a relative value, since I can't get the relative value).

    Can you post a link to your example so we can see what is happening in action please?

    Allan
  • earacheflearachefl Posts: 11Questions: 0Answers: 0
    Ah... I had set an inline style on the tables, but it was getting destroyed on the second call and replaced with the attribute "style='width: 100px'". Putting the style in a stylesheet and marking !important clears it up. Thanks!
This discussion has been closed.