Problems occur when switching using the jqueryDataTable tab

$("- sharpnav-tabs li"). On ("click",function () {

)
        $("-sharpnav-tabs li").removeClass("active");
        $(this).addClass("active");
        that.currentIndex=$(this).index();
        that.initTableData();

})

initTableData:function () {

    var that = this;
    console.log(that.currentIndex)
    var returnData = "";
    var columns="";
    if(that.currentIndex==0){
        returnData = [
            {pjwd:"b",ejzb:"",pjzb:"",sjly:"()",ccc:"14.16",bb:"22"},
            {pjwd:"",ejzb:"",pjzb:"",sjly:"()",ccc:"14.16",bb:"22"},
            {pjwd:"",ejzb:"",pjzb:"",sjly:"()",ccc:"14.16",bb:"22"},
            {pjwd:"",ejzb:"",pjzb:"",sjly:"()",ccc:"14.16",bb:"22"},
            {pjwd:"",ejzb:"",pjzb:"",sjly:"()",ccc:"14.16",bb:"22"},
        ];

        columns=[
                {"data": null, title: "", "width": "5%"},
                {"data": "ejzb", title: "", "width": "12%"},
                {"data": "pjzb", title: "", "width": "12%"},
                {"data": "sjly", title: "", "width": "12%"},
                {"data": "ccc", title: "", "width": "12%"},
                {"data": "pjwd", title: "", "width": "12%"},
        ];
    }
    if(that.currentIndex==1){
        returnData = [
            {pjwd:"b",ejzb:"",pjzb:"",sjly:"()",ccc:"14.16",bb:"22"},
            {pjwd:"",ejzb:"",pjzb:"",sjly:"()",ccc:"14.16",bb:"22"},
            {pjwd:"",ejzb:"",pjzb:"",sjly:"()",ccc:"14.16",bb:"22"},
            {pjwd:"",ejzb:"",pjzb:"",sjly:"()",ccc:"14.16",bb:"22"},
            {pjwd:"",ejzb:"",pjzb:"",sjly:"()",ccc:"14.16",bb:"22"},
        ];
        columns=[
                {"data": null, title: "", "width": "5%"},
                {"data": "pjwd", title: "/", "width": "10%"},
                {"data": "ejzb", title: "", "width": "12%"},
                {"data": "pjzb", title: "", "width": "12%"},
                {"data": "sjly", title: "", "width": "12%"},
                {"data": "ccc", title: "", "width": "12%"},
                {"data": "bb", title: "", "width": "12%"},
        ];
       
    }
    if(that.currentIndex==2){
        returnData = [
            {pjwd:"c",ejzb:"",pjzb:"",sjly:"()",ccc:"14.16",bb:"22"},
            {pjwd:"",ejzb:"",pjzb:"",sjly:"()",ccc:"14.16",bb:"22"},
            {pjwd:"",ejzb:"",pjzb:"",sjly:"()",ccc:"14.16",bb:"22"},
            {pjwd:"",ejzb:"",pjzb:"",sjly:"()",ccc:"14.16",bb:"22"},
            {pjwd:"",ejzb:"",pjzb:"",sjly:"()",ccc:"14.16",bb:"22"},
        ];
        columns=[
                {"data": null, title: "", "width": "5%"},
                {"data": "pjwd", title: "/", "width": "10%"},
                {"data": "ejzb", title: "", "width": "12%"},
                {"data": "pjzb", title: "", "width": "12%"},
                {"data": "sjly", title: "", "width": "12%"},
                {"data": "ccc", title: "", "width": "12%"},
                {"data": "bb", title: "", "width": "12%"},
        ];

    }
    // $.fn.dataTable.tables( {visible: true, api: true} ).columns.adjust();
     var t=$("-sharpunit-table").dataTable({
            data: returnData,
            language: trans(),
            sDom: ""top"i",
            pageLength: 10,
            autoWidth: false,
            destroy: true,
            info: true,
            ordering: false,
            columns: columns,
           
    });
}

clipboard.png

Mar.02,2021
Menu