datatables group and change data

datatables group and change data

kasprokaspro Posts: 4Questions: 1Answers: 0
edited April 2018 in Free community support
  1. Data from static JSON
  2. Add row in ready
var t = $('#example').DataTable();
t.row.add([
            ...
        ]).draw(false);
  1. Group
 $('#example').DataTable({
            paging: false,
            searching: false,
            //ordering: false,
            info: false,
            columnDefs: [
            {
                "targets": [ 0 ],
                //"visible": false,
                "orderable": true
            },
            {
                "targets": [1, 2, 3, 4, 5],
                "orderable": false
            }],
            order: [[0, 'asc']],
            //data: dataSet,
            rowGroup: {
                startRender: null,
                endRender: function (rows, group) {
                    return $('<tr/>')
                        .append('<td colspan="3">Place ' + group + '</td>')
                        .append('<td><span class="badge" style="font-size: 21px; display: inline-block;" >0 ед.</span></td>')
                        .append('<td colspan="3"><td/>');
                },
                dataSrc: 0
            }
  1. Add new t.row.add([
    ...
    ]).draw(false);
  2. Change data
  3. var t = $('#example').DataTable();
    t.cell(rowId, 0).data(box).draw();

After changing the data to the last round, the groups are not updated, only after changing all starts working normally, what do I do wrong?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    The grouping information should be updated upon the draw() call. I've put a little example together here.

    Can you link to a test case showing the issue so we can help debug it please.

    Allan

  • kasprokaspro Posts: 4Questions: 1Answers: 0
    edited April 2018

    Please, change value in combobox from 1 to 2, after duplicate group!

    After change all combobox, work normal. link

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    I'm afraid I don't really understand the example - its quote complex as a test case! Can you give me step by step instructions for what to do?

    Allan

  • kasprokaspro Posts: 4Questions: 1Answers: 0

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin
    Answer ✓

    Fixed here: http://live.datatables.net/toyukuwo/9/edit

    The problem was that when you read the value from the DOM it is read as a string. Thus "2" was being being set as the value for the cell, not 2 (as a number). RowGroup uses strict type checking - thus the issue.

    cell.data(box * 1);
    

    Was what I used to fix it.

    Allan

  • kasprokaspro Posts: 4Questions: 1Answers: 0

    Thank you!

This discussion has been closed.