2

嗨,我遇到了数据表(jquery)的问题,我自己无法解决。任何人都可以帮助我或给我一个提示吗?

问题是我的数据表的标题被移动并且格式不正确,如下图所示。

![在此处输入图像描述][1]

但是当我单击一个条目以对其进行排序时,它会更改格式并且一切正常。

![在此处输入图像描述][2]

我已经使用 jquery ui 选项卡将数据表包含在 jquery ui 对话框中。我的代码看起来像这样。

    <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>

提前谢谢提示..

4

1 回答 1

2

单击选项卡单击时,您必须添加触发器。在你的情况下,它会是这样的:

首先将数据表添加到变量中:

var oTable = $('#singleusertable').dataTable({
    ..

});

然后在您单击第二个选项卡后重新加载。像这样:

$("a[href=#tabs-2]").click(function()
{
    oTable.fnReloadAjax();
}); 

您的最终脚本将如下所示:

<script>
var oTable  = null;
$(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();

    $("#controllerTab a[href=#tabs-2]").click(function()
    {
        oTable.fnDraw();
    });     
});

$(document).ready(function() {
    oTable = $('#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']]
    });
});
于 2012-11-11T15:59:23.710 回答