DataTables Width, "bDestroy": true
DataTables Width, "bDestroy": true
robertbrower
Posts: 158Questions: 1Answers: 0
I'm having a problem with the jQuery DataTables plugin. The first time I invoke the $.dataTable() it produces a nice looking table. But the second time I call it (To reinitialize the table), the column widths are not correct, i.e. the table is squished horizontally. In all cases, the same code is called so I do not understand. Furthermore, this does not happen with Firefox, only with Internet Explorer, although Explorer is my target browser.
My javascript (inside the success handler for an ajax call):
success: function (result) {
if (oApplicationsTable != undefined) {
oApplicationsTable.fnDestroy();
oApplicationsTable = null;
}
$(this).html(result.d);
oApplicationsTable = $("#applicationsTable").dataTable({
"bDestroy": true,
"bAutoWidth": false,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bLengthChange": false,
"aLengthMenu": [[10, 20, -1], [10, 20, "All"]],
"iDisplayLength": 10,
"sDom": '<"H"ilfr><"applicationsList"t><"F"p>',
"aoColumns": [
/* checkbox */{"bSortable": false, "bSearchable": false, "bVisible": true },
/* Name */{"bSearchable": false, "bVisible": true },
/* LongName */{"bSearchable": true, "bVisible": false },
/* Location */{ },
/* Category */{ },
/* Description */{"bSearchable": false, "bVisible": true },
/* LongDescription */{"bSearchable": true, "bVisible": false }
],
"aaSorting": [[2, "asc"]],
});
My markup looks like this:
<%--EDIT REPORT GROUPS DIALOG--%>
Name
LongName
Location
Category
Description
LongDescription
I have spent an aweful lot of time reading other similar posts, but have not found the answer. Thanks for reading.
Robert
My javascript (inside the success handler for an ajax call):
success: function (result) {
if (oApplicationsTable != undefined) {
oApplicationsTable.fnDestroy();
oApplicationsTable = null;
}
$(this).html(result.d);
oApplicationsTable = $("#applicationsTable").dataTable({
"bDestroy": true,
"bAutoWidth": false,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bLengthChange": false,
"aLengthMenu": [[10, 20, -1], [10, 20, "All"]],
"iDisplayLength": 10,
"sDom": '<"H"ilfr><"applicationsList"t><"F"p>',
"aoColumns": [
/* checkbox */{"bSortable": false, "bSearchable": false, "bVisible": true },
/* Name */{"bSearchable": false, "bVisible": true },
/* LongName */{"bSearchable": true, "bVisible": false },
/* Location */{ },
/* Category */{ },
/* Description */{"bSearchable": false, "bVisible": true },
/* LongDescription */{"bSearchable": true, "bVisible": false }
],
"aaSorting": [[2, "asc"]],
});
My markup looks like this:
<%--EDIT REPORT GROUPS DIALOG--%>
Name
LongName
Location
Category
Description
LongDescription
I have spent an aweful lot of time reading other similar posts, but have not found the answer. Thanks for reading.
Robert
This discussion has been closed.
Replies
Allan
"you could call fnDestroy and then replace the table HTML, set the width to 100% and then initialise the table."
This is the solution.
@robertbrower: I have same problem for column width. Can you post your solved code.
I want to see where I am doing mistake.
the table section changes and the width of the table is wider than the toolbar header and footer.
I am correcting this by doing the following
[code]
$('#example').css('width', '')
[/code]
Hope this helps.
Thanks !