简体   繁体   English

添加特定列后未显示jQuery Datatable列

[英]jQuery Datatable column not shown after adding a certain column

I have a data-table js table starts like:- 我有一个数据表的js表开始像:

<link rel="stylesheet" href="http://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.css">

<table id="demo-foo-filtering" class="table table-striped table-bordered 
toggle-circle m-b-0" style="width:100%">

               <colgroup>
                        <col style="width:5%;"/>
                        <col style="width:10%;"/>

                        <col style="width:20%;"/>
                        <col style="width:20%;"/>
                        <col style="width:10%;"/>
                        <col style="width:10%;"/>


                    </colgroup>

                   <thead class="pattern-table">
                    <tr>
                        <th></th>
                        <th>카테고리</th>

                        <th>해시(MD5)</th>
                        <th>파일명</th>
                        <!-- New UI requirement, column name changed.-->
                        <th>분석장비</th> <!-- New UI requirement, column name changed.-->
                        <th>등록일</th>
                    </tr>
                    </thead>

JQuery Code is jQuery代码是

dtTable = $('#demo-foo-filtering').DataTable({
                ajax: {
                    url:"/secure-log/black-list/list",
                    type:"POST",
                    "data": function (d) {
                        d.perpage = $("#perpage").val();
                        d.search_source = $("#search_source").val();
                        d.search_keyword = $("#search_keyword").val();
                    }
                },
                dataFilter: function(data){
                var json = jQuery.parseJSON( data );
                json.recordsTotal = json.total;
                json.recordsFiltered = json.total;
                json.data = json.list;

                return JSON.stringify( json ); // return JSON string
            },
            "initComplete": function(settings, json){
              $('#divTotal').text("총 "+json.recordsFiltered.toLocaleString() + "건");
            },
            error: function(xhr, error, thrown) {
                alert(error);
                error(xhr, error, thrown);
            },
            dom: 'Bfrtip',
            "pagingType": "full_numbers",
            fixedHeader: true,
            "scrollY" : "700px",
            serverSide: true,
            pageLength: $("#perpage").val(),
            bLengthChange: false,
            processing: true,
            searching: false,
            sort: false,
            paging: true,
            info: false,
            deferRender: true,
            responsive: true,
            autoWidth : true,
            //select: 'single',
            "sPaginationType": "full_numbers",

            columns: [
                {
                  data:null
                },
                {
                    data : "rule_name",
                    label: "카테고리" //New UI requirement, column name changed.
                },

                {
                    data : "md5",
                    label: "유해파일(MD5)" //New UI requirement, column name changed.
                },
                {
                    data : "mal_file_name",
                    label: "파일명" //New UI requirement, column name changed.
                },
                {
                    data : "description",
                    label: "분석장비"
                },
                {
                    data : "cre_dt",
                    label: "등록일"
                }
            ],
            columnDefs : [
                {
                    targets : 0,

                    render : function (data, type, row, meta) {

                        var btnHtml = "<input type='checkbox' name='dtSelector' value='"+ meta.row + "'/>";

                        return btnHtml;
                    }
                }



            ]




    }
}

This code retrieves data from the server and it displays data over the screen well. 此代码从服务器检索数据,并在屏幕上很好地显示数据。 However, a problem begins if I add one more column to the table. 但是,如果我在表中再增加一列,就会出现问题。 This column contains a large length of string, URL. 此列包含很长的字符串URL。

As I add it, the last three columns gets display:none and the table rows are displayed none, too. 当我添加它时,将display:none最后三列display:none ,并且表行也未显示。 I have been trying a lot of things, such as readjusting width %, make the hidden columns visible in the column defs. 我一直在尝试很多事情,例如重新调整宽度%,使隐藏的列在列defs中可见。

I guess If I could adjust this particular column width, and make the large string displayed in multiple lines rather than a single line. 我猜想是否可以调整此特定的列宽,并使大字符串显示为多行而不是一行。 This issue will be resolved. 此问题将得到解决。 Do you have any idea to solve it? 您有解决的主意吗?

If you need me to be more specific in the elaboration of a problem, tell me please. 如果您需要我在处理问题时更加具体,请告诉我。

Good table 好桌子 在此处输入图片说明

after I add URL column with large string value 在我添加具有大字符串值的URL列之后 在此处输入图片说明

I sorted it out after trimming large URL string variables. 我修剪掉较大的URL字符串变量后进行了整理。 If you guys have any other ideas how to avoid it. 如果你们还有其他想法如何避免这种情况。 You are more than welcomed to answer it. 非常欢迎您回答。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM