Column Size settings are not working
Column Size settings are not working
Giblin
Posts: 4Questions: 0Answers: 0
I'm working in v 1.9.4 and using jQuery UI v 1.10.3.
I have searched all over for an answer to this and nothing I'm finding is working.
I have a page that uses UI tabs. In that tab is a button that does an ajax call for new tables. The call returns fully formatted html tables that are then appended to a div on the page inside the tab using jQuery and then have the dataTable initialize called on the new table. The table is never hidden so that should not be an issue here. That all works great but then when I try to set the width of the columns nothing happens its like its getting over written or ignored. Here's my code.
HTML
[code]
1
2
3
4
Data 1
Data 2
Data 3
Data 4
[/code]
JS
[code]
$('#myprojects').on('click',function(){
$('#userprojects').val($('#myprojects').data('myid'));
$.ajax({
type: 'POST',
url: 'myservice.php',
cache:false,
data: {userID: $('#myprojects').data('myid') },
dataType: 'json',
success: function(data, textStatus){
if(data.error){
alert(data.error_msg);
}
else{
$('#tables').empty();
$('#tables').append(data.que);
var toBeStartedTabel = $('#toBeStarted').dataTable({"bAutoWidth": false,
"sScrollX": "100%",
"aoColumns": [
/*id*/{ "sWidth": "50px"},
/*client*/{ "sWidth": "100px"},
/*project*/null,
/*period*/null,
/*priority*/null,
/*in*/null,
/*due*/null,
/*Note*/{ "sWidth": "100px"}
]
});
toBeStartedTabel.fnAdjustColumnSizing();
$('#tables').append(data.inprocess);
var inprocessTabel = $('#inProcess').dataTable();
$('#tables').append(data.rework);
var inprocessTabel = $('#rework').dataTable();
$('#tables').append(data.review);
var inprocessTabel = $('#review').dataTable();
}
},
error: function(xhr, textStatus, errorThrown){
alert(errorThrown);
alert(xhr.responseText);
//alert(Object.keys(xhr));
}
});
});
[/code]
I have tried just about every solution on these forms and stack overflow with no luck.
Thank you
UPDATE: It appears that any and all setting in the dataTable function call is being ignored. I just tried to add aaSorting to the call and its being ignored as well. Can anyone shed some light on this please.
I have searched all over for an answer to this and nothing I'm finding is working.
I have a page that uses UI tabs. In that tab is a button that does an ajax call for new tables. The call returns fully formatted html tables that are then appended to a div on the page inside the tab using jQuery and then have the dataTable initialize called on the new table. The table is never hidden so that should not be an issue here. That all works great but then when I try to set the width of the columns nothing happens its like its getting over written or ignored. Here's my code.
HTML
[code]
1
2
3
4
Data 1
Data 2
Data 3
Data 4
[/code]
JS
[code]
$('#myprojects').on('click',function(){
$('#userprojects').val($('#myprojects').data('myid'));
$.ajax({
type: 'POST',
url: 'myservice.php',
cache:false,
data: {userID: $('#myprojects').data('myid') },
dataType: 'json',
success: function(data, textStatus){
if(data.error){
alert(data.error_msg);
}
else{
$('#tables').empty();
$('#tables').append(data.que);
var toBeStartedTabel = $('#toBeStarted').dataTable({"bAutoWidth": false,
"sScrollX": "100%",
"aoColumns": [
/*id*/{ "sWidth": "50px"},
/*client*/{ "sWidth": "100px"},
/*project*/null,
/*period*/null,
/*priority*/null,
/*in*/null,
/*due*/null,
/*Note*/{ "sWidth": "100px"}
]
});
toBeStartedTabel.fnAdjustColumnSizing();
$('#tables').append(data.inprocess);
var inprocessTabel = $('#inProcess').dataTable();
$('#tables').append(data.rework);
var inprocessTabel = $('#rework').dataTable();
$('#tables').append(data.review);
var inprocessTabel = $('#review').dataTable();
}
},
error: function(xhr, textStatus, errorThrown){
alert(errorThrown);
alert(xhr.responseText);
//alert(Object.keys(xhr));
}
});
});
[/code]
I have tried just about every solution on these forms and stack overflow with no luck.
Thank you
UPDATE: It appears that any and all setting in the dataTable function call is being ignored. I just tried to add aaSorting to the call and its being ignored as well. Can anyone shed some light on this please.
This discussion has been closed.
Replies
Btw - your aoColumns has 8 columns defined in it, but your HTML only has 4. Probably not the issue (we'll need a test case for that), but possibly causing some issues.
Allan
Sorry about not having a test case I'm new here. I will try to build one up, for the working model is protected because of data sensitivity. Ill reply here again when I have a working case study running.
Thank you again
Giblin
Sorry to have bothered you I found the problem it was a duplicate code issue that was overwriting my changes.
Thanks
Giblin