Bootstrap-Table: How to hide a column without deleting it from the DOM?

后端 未结 4 1882
北恋
北恋 2021-01-21 09:49

I\'m having problems with the Bootstrap-Table plugin: https://github.com/wenzhixin/bootstrap-table

I have a hidden ID column in the table I need to hide. But I can\'t do

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-21 10:10

    You almost got it right, the problem is that your jQuery selector is wrong.

    Css's :nth-child doesn't start at 0 ;)

    This will work:

    $('#delegateTable').bootstrapTable({
        onPostBody : function() {
            $('#delegateTable').find('th:nth-child(1), tr td:nth-child(1)').hide();
            alert('column hidden');                 
        }
    });
    

    See this example.

    You can also replace this javascript with CSS:

    #delegateTable th:nth-child(1), #delegateTable tr td:nth-child(1){
      display: none;
    }
    

提交回复
热议问题