【问题标题】:How can I show more than 1 row in responsive view of Datatables.net?如何在 Datatables.net 的响应视图中显示超过 1 行?
【发布时间】:2019-11-02 21:28:48
【问题描述】:

这是我在桌面模式下的表格:

在响应式或移动视图中,目前只有用户可以在不点击 + 按钮的情况下查看国家名称,但我想在不点击 + 按钮和用户点击 + 按钮时显示(名称、购买价格、销售价格)用户其他列(日期、图表、国家名称)。
我如何使用 datatables.net 的表来做到这一点?

【问题讨论】:

    标签: jquery html-table datatables


    【解决方案1】:

    文档:

    https://datatables.net/extensions/responsive/examples/column-control/columnPriority.html

    因此,您必须在 DataTable 构造函数中正确使用 responsivePriority in columnDefs

    $(document).ready(function() {
        $('#example').DataTable( {
            responsive: true,
            columnDefs: [
                { responsivePriority: 1, targets: 1 }, // name
                { responsivePriority: 2, targets: 2 }, // buy price
                { responsivePriority: 3, targets: 3 }, // sell price
                { responsivePriority: 4, targets: 0 },
                { responsivePriority: 5, targets: 4 },
                { responsivePriority: 6, targets: 5 }
            ]
        } );
    } );
    

    编辑

    好的,这更复杂...首先,将其用于fixed columnsHow to fixed the last column of a responsive DataTable,然后使用row_details插件(您必须通过迭代当前行来填充每一行内的数据):@ 987654323@

    【讨论】:

    • 嗨@Dani 我知道这一点,但我已经告诉我想显示(名称、购买价格、销售价格)以显示我的网站何时显示在移动设备上,目前仅显示国家名称移动设备,如果我想显示更多,我应该点击 + 按钮,但我想默认显示 3 列,如果用户想看到更多点击 + 按钮,请看这张图片:(名称,购买价格,销售价格)>>bit.ly/31J6h8e
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-04-25
    • 1970-01-01
    • 1970-01-01
    • 2020-01-11
    • 1970-01-01
    • 2021-05-23
    • 2023-02-06
    相关资源
    最近更新 更多