Column Visibility with Custom Search Fields

后端 未结 1 1279
醉酒成梦
醉酒成梦 2021-01-24 03:30

I am trying to create a datatable with custom search and column visibility.

What I have done is -

HTML

    
相关标签:
1条回答
  • 2021-01-24 03:51

    SOLUTION

    You're using two thead elements, make it one with two rows instead as shown below.

    <thead>
        <tr>
            <th>Employee name</th>
            <th>Salary</th>
            <th>Position</th>
            <th>City</th>
            <th>Extension</th>
            <th>Joining date</th>
            <th>Age</th>
        </tr>
        <tr>
            <td><input type="text" id="0"  class="employee-search-input"></td>
            <td><input type="text" id="1" class="employee-search-input"></td>
            <td><input type="text" id="2" class="employee-search-input" ></td>
            <td><input type="text" id="3" class="employee-search-input" ></td>
            <td><input type="text" id="4" class="employee-search-input" ></td>
            <td  valign="middle"><input  readonly="readonly" type="text" id="5" class="employee-search-input datepicker" ></td>
            <td><input type="text" id="6" class="employee-search-input" ></td>
        </tr>
    </thead>
    

    Also in this case you need to use orderCellsTop: true option to tell DataTables to use top row for sorting.

    DEMO

    See this jsFiddle for code and demonstration.

    0 讨论(0)
提交回复
热议问题