最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to use Rowspan in datatable - Stack Overflow

programmeradmin3浏览0评论

I'm using Spring Boot and MySQL. I have data in following structure.

I try to show it like following structure. I'm using datatable Datatable link, I tried using api(s) of datatable and javascript in many ways to do, but I couldn't make it.

Few links describe to be done with $('#datatable').DataTable({'rowsGroup': [0]}), but not working. I implemented using map in Java. But I feel better if I do it in front-end

  • Datetime always unique and each Datetime has 6 records always

  • Value should be sum(value)/(distinct Datetime)

  • If null/empty values are passing in feedback, ignore title and feedback only

How can I solve this?

I'm using Spring Boot and MySQL. I have data in following structure.

I try to show it like following structure. I'm using datatable Datatable link, I tried using api(s) of datatable and javascript in many ways to do, but I couldn't make it.

Few links describe to be done with $('#datatable').DataTable({'rowsGroup': [0]}), but not working. I implemented using map in Java. But I feel better if I do it in front-end

  • Datetime always unique and each Datetime has 6 records always

  • Value should be sum(value)/(distinct Datetime)

  • If null/empty values are passing in feedback, ignore title and feedback only

How can I solve this?

Share Improve this question edited Nov 25, 2019 at 21:21 halfer 20.4k19 gold badges109 silver badges202 bronze badges asked Jul 12, 2018 at 11:57 varmanvarman 8,9026 gold badges24 silver badges56 bronze badges 1
  • Possible duplicate of How to add Rowspan in JQuery datatables – cнŝdk Commented Jul 12, 2018 at 12:06
Add a ment  | 

1 Answer 1

Reset to default 5

You need to use datatable rowsGroup plugin. See the link - datatables-rowsgroup or New 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 to view the example.

发布评论

评论列表(0)

  1. 暂无评论