datatables with details control : how to show details after refresh

datatables with details control : how to show details after refresh

tigrou91430tigrou91430 Posts: 6Questions: 4Answers: 0
edited February 2017 in Free community support

Hello, I use datatables with details-control.
But, I would like to know how I can keep my selection.

For exemple :
I have 4 lines

  • LINE A
  • LINE B
    DETAILS LINE B
  • LINE C
  • LINE D
    DETAILS LINE D

And all the 5 minutes, I have a fonction for refresh my table
But I would like to keep open my details controls and my selection

Thanks you

This is my function

$('#table').dataTable(
{
'bProcessing' : true,
'bServerSide' : false,
'lengthMenu' : [ [ -1, 15, 30, 90 ],
[ "Tous", 15, 30, 90 ] ],
"order" : [ [ 1, "desc" ] ],
'sAjaxSource' : 'database/get_table.php',
"bAutoWidth" : false,
"stateSave" : true,
"aoColumns" : [ {
"className" : 'details-control',
"orderable" : false,
"defaultContent" : '',
"mData" : "",
"sWidth" : "5%"
}, {
"sName" : "",
"sWidth" : "95%",
"mData" : "id"
} ],
"fnDrawCallback" : function(settings) {
},
"fnRowCallback" : function(nRow, aData,
iDisplayIndex) {
if ($.inArray(aData["id"],
autogroupArray) !== -1) {
$(nRow).addClass('selected');
}
}
});

$('#table tbody').on(
'click',
'tr',
function() {
var tr = $(this).closest('tr');
var row = table.row(tr);

                            if (row.child.isShown()) {
                                if (row.data() !== undefined) {
                                    tableArray.unset(tableTable
                                            .cell(row.index(), 1).data());
                                    row.child.hide();
                                    tr.removeClass('shown');
                                }
                            } else {
                                if (row.data() !== undefined) {
                                    row
                                            .child(
                                                    format(row
                                                            .data().id))
                                            .show();
                                    tr.addClass('shown');

                                    tableArray.push(tableTable
                                            .cell(row.index(), 1).data());
                                }
                            }
                            if (row.data() !== undefined) {
                                $(this).toggleClass('selected');
                            }

                            Array.prototype.unset = function(val) {
                                var index = this.indexOf(val);
                                if (index > -1) {
                                    this.splice(index, 1);
                                }
                            };
                        });
This discussion has been closed.