Hi i’ve got a problem with datatables (jquery) i cannot solve my own. can anybody help me or give me a hint`?
the problem is that the header of my datatables is shifted and not formatted well as you can see in the pic below.
![enter image description here][1]
but when i click on one entry in order to sort it it changes formatting and everything works fine.
![enter image description here][2]
i have included the datatable in a jquery ui dialog using jquery ui tabs. my code looks like this.
<script>
$(function() {
$("#rt").treeview();
$("button").button({
icons: {primary: "ui-icon-person"}}).click(function() {
var id = this.id;window.location="rightsmanagement?nutzerrechte_vergeben&show=3&refine=";
});
});
$.fn.tabbedDialog = function () {
this.tabs();
var wWidth = $(window).width();
var dWidth = wWidth * 0.8;
var dialogOptions = {
modal: true,width: dWidth,minHeight: 520};
this.dialog(dialogOptions);
this.find('.ui-tab-dialog-close').append($('a.ui-dialog-titlebar-close'));
this.find('.ui-tab-dialog-close').css({'position':'absolute','right':'0', 'top':'13px'});
this.find('.ui-tab-dialog-close > a').css({'float':'none','padding':'0'});
var tabul = this.find('ul:first');
this.parent().addClass('ui-tabs').prepend(tabul).draggable('option','handle',tabul);
this.siblings('.ui-dialog-titlebar').remove();
tabul.addClass('ui-dialog-titlebar');
}
$(document).ready(function() {
$('#controllerTab').tabbedDialog();
});
$(document).ready(function() {
$('#singleusertable').dataTable({
"sScrollY": "280px",
"bPaginate": false,
"bAutoWidth": false,
"oLanguage": {"sUrl": "style/table/sprache.txt"},
"aoColumnDefs": [
{ "bVisible": false, "aTargets": [ 0 ] },
{ "sTitle": "Benutzername", "aTargets": [ 1 ] },
{ "sTitle": "Vorname", "aTargets": [ 2 ] },
{ "sTitle": "Nachname", "aTargets": [ 3 ] },
{ "sTitle": "Personalnummer", "aTargets": [ 4 ] },
{ "sTitle": "Abteilung", "aTargets": [ 5 ] },
{ "bVisible": false, "aTargets": [ 6 ] },
{ "sWidth": "25%", "aTargets": [ 1] },
],"aaSorting": [[0, 'desc']]
});
});
</script>
thx in advance for tips..
You have to add a trigger when you click on the tab click. In your case it would be something like this:
First of all add the datatables to a variable:
and then just reload after you are clicking at the second tab. Like this:
Your final script will look like this: