Jquery 数据表响应无法正常工作

标签 jquery datatable datatables

我正在使用带有响应式插件的数据表,

https://cdn.datatables.net/responsive/2.1.1/css/responsive.dataTables.css
https://cdn.datatables.net/responsive/2.1.1/js/dataTables.responsive.js

这是我的屏幕结果:

桌面 View : view on desktop mode

移动 View 顶部:

mobile view 1

移动 View 底部:

mobile view 2

我的 JS 代码:

    dataTable = $('#agency_data').DataTable({
    "processing":true,
    "serverSide":true,
    "order":[],
    responsive: true,

    "language": {
    "infoFiltered": ""
    },
    "ajax":{
        url:base_url+"/agency-listing",
        type:"POST"
    },
    "columnDefs":[
        {
            "targets":[0, 3], //first and last not sortable
            "orderable":false,
        },          
    ],

}); 

我的表格的 HTML:

        <table id="agency_data" class="table table-bordered table-striped">
        <thead>
        <tr class="info">
        <th width="10%">ID</th>
        <th width="15%">Agency Code</th>
        <th width="65%">Agency Name</th>
        <th width="15%">Action</th>
        </tr>
        </thead>
        </table>

JSFIDDLE: HERE

问题:

1) 在移动端 View 中,如何获得长组织名称,完美显示?喜欢BR?

2)如何摆脱底部的水平滚动,以便用户无需在移动 View 上滚动?

最佳答案

在表中添加:width="100%"解决了问题

<table id="agency_data" class="table table-bordered table-striped" width="100%">

关于Jquery 数据表响应无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45851452/

相关文章:

c# - 更改 DataGrid 的列宽

grails - 如何在不使用数据库切片的情况下在 View 中显示大列表?

javascript - DataTables 更改所有页面上的复选框

javascript - 使用 scrollTop 替换粘性导航栏以获得 60 FPS 性能的替代方案?

javascript - 如何在使另一个 div 不可滚动的同时在 div 内滚动 div

jquery - TwitterBootstrap event.latedTarget() 不返回单击的按钮

jquery - 全局搜索列包含选择框的数据表

javascript - [Wordpress + PHP + MySQL]插件内的数据库SELECT查询没有返回结果

c# - LINQ 查询以按不同类别/子类别计数

angular - 在 Angular 2 中重新渲染数据表 - dtInstance.then 错误