jquery datatables hide column

前端 未结 13 1394
灰色年华
灰色年华 2020-12-02 11:59

Is there a way with the jquery datatables plugin to hide (and show) a table column?

I figured out how to reload the table data: using fnClearTable and <

13条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-02 12:28

    Hope this will help you. I am using this solution for Search on some columns but i don't want to display them on frontend.

    $(document).ready(function() {
            $('#example').dataTable({
                "scrollY": "500px",
                "scrollCollapse": true,
                "scrollX": false,
                "bPaginate": false,
                "columnDefs": [
                    { 
                        "width": "30px", 
                        "targets": 0,
                    },
                    { 
                        "width": "100px", 
                        "targets": 1,
                    },
                    { 
                        "width": "100px", 
                        "targets": 2,
                    },              
                    { 
                        "width": "76px",
                        "targets": 5, 
                    },
                    { 
                        "width": "80px", 
                        "targets": 6,
                    },
                    {
                        "targets": [ 7 ],
                        "visible": false,
                        "searchable": true
                    },
                    {
                        "targets": [ 8 ],
                        "visible": false,
                        "searchable": true
                    },
                    {
                        "targets": [ 9 ],
                        "visible": false,
                        "searchable": true
                    },
                  ]
            });
        });
    

提交回复
热议问题