【问题标题】:How to use Rowspan in datatable如何在数据表中使用 Rowspan
【发布时间】:2018-12-20 15:39:17
【问题描述】:

我正在使用 Spring Boot 和 MySQL。我有以下结构的数据。

我尝试将其显示为以下结构。我正在使用数据表Datatable link,我尝试通过多种方式使用数据表和javascript的api,但我做不到。

很少有链接描述使用$('#datatable').DataTable({'rowsGroup': [0]}) 完成,但不起作用。我在 Java 中使用 map 实现。但是如果我在前端做,我会感觉更好

  • 日期时间总是唯一的,每个日期时间总是有 6 条记录

  • 值应该是sum(value)/(distinct Datetime)

  • 如果在反馈中传递 null/空值,仅忽略标题和反馈

我该如何解决这个问题?

【问题讨论】:

标签: javascript jquery datatable datatables


【解决方案1】:

您需要使用数据表 rowsGroup 插件。见链接—— datatables-rowsgroupNew RowsGroup plugin

$(document).ready( function () {
  var data = [
    ['1', 'David', 'Maths', '80'],
    ['1', 'David', 'Physics', '90'],
    ['1', 'David', 'Computers', '70'],
    ['2', 'Alex', 'Maths', '80'],
    ['2', 'Alex', 'Physics', '70'],
    ['2', 'Alex', 'Computers', '90'],
  ];
  var table = $('#example').DataTable({
    columns: [
        {
            name: 'first',
            title: 'ID',
        },
        {
            name: 'second',
            title: 'Name',
        },
        {
            title: 'Subject',
        }, 
        {
            title: 'Marks',
        },
    ],
    data: data,
    rowsGroup: [
      'first:name',
      'second:name'
    ],
    pageLength: '20',
    });
} );

Click here 查看示例。

【讨论】:

  • 如果没有动态列比如何在整个网格中实现行跨度..我们需要在rowsGroup中传递什么..
猜你喜欢
  • 2015-11-12
  • 2017-06-29
  • 2012-04-07
  • 2022-12-11
  • 1970-01-01
  • 1970-01-01
  • 2015-02-02
  • 1970-01-01
  • 2013-12-23
相关资源
最近更新 更多