jquery datatables hide column

前端 未结 13 1360
灰色年华
灰色年华 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条回答
  •  抹茶落季
    2020-12-02 12:24

    For anyone using server-side processing and passing database values into jQuery using a hidden column, I suggest "sClass" param. You'll be able to use css display: none to hide the column while still being able to retrieve its value.

    css:

    th.dpass, td.dpass {display: none;}
    

    In datatables init:

    "aoColumnDefs": [ { "sClass": "dpass", "aTargets": [ 0 ] } ] // first column in visible columns array gets class "dpass"
    

    //EDIT: remember to add your hidden class to your thead cell also

提交回复
热议问题