在固定列上实现数据表重叠问题

时间:2018-06-23 03:56:14

标签: jquery twitter-bootstrap datatable datatables

我有下表

<table  class="table display nowrap" cellspacing="0" width="100%" style="width:100%" id="pageRoleTable">
                            <thead class="text-primary">
                            <th>Name</th>
                            @foreach($role as $key=>$value)
                            <th>{{$value->role_name}}</th>
                          @endforeach
                            </thead>
                            <tbody>
                            @foreach($page as $key=>$value)
                            <tr>
                                <td>{{$value->page_name}}</td>
                                @for($i=0;$i<count($role);$i++)
                                <td><div class="checkbox checkbox-inline">
                                        <label>
                                            <input type="checkbox" data-pageId="{{$value->id}}"  data-role="{{$role[$i]['id']}}" name="role_access" value="edit">

                                        </label>
                                    </div>
                                </td>
                                    @endfor

                            </tr>

                                @endforeach


                            </tbody>
                            <tfoot>
                            <tr>
                                <td></td>
                                @foreach($role as $key=>$value)
                                    <td><button class="btn btn-info"  data-role="{{$value->id}}">
                                        <span class="btn-label">
                                            <i class="material-icons">priority_high</i>
                                        </span>
                                            Info
                                            <div class="ripple-container"></div></button></td>
                                @endforeach
                            </tr>
                            </tfoot>
                    </table>

javascript

 $('#pageRoleTable').DataTable({


                    scrollY:        "300px",
                    scrollX:        true,
                    scrollCollapse: true,
                    paging:         false,
                    fixedColumns:   {
                        leftColumns: 4

                    }
                });

但是在重叠固定列文本内容之后

enter image description here 遵循了许多答案,但没有帮助我 Datatable Fixed Column (Right Only) Issue DataTable Fixed Column with Bootstrap's dropdown

任何人都可以帮助我如何解决此问题

1 个答案:

答案 0 :(得分:0)

我已通过设置td and th的背景色来解决上述问题

.table tbody tr td{background:#fff /*set your own color*/} 
.table thead tr th{background:#fff /*set your own color*/}