dvv
dvv

Reputation: 138

Row grouping and checkboxes

I have a table powered by jQuery DataTables with checkbox in the first column to edit the row data. And I have a time column with duplicate values so I kept the row grouping on that time column.

Now I only need to show one checkbox for grouped row data. For the grouped time data I want to show only first checkbox to edit.

enter image description here

Upvotes: 2

Views: 1344

Answers (1)

Gyrocode.com
Gyrocode.com

Reputation: 58880

SOLUTION

Row grouping could be done with RowsGroup plugin for jQuery DataTables. Checkboxes could be implemented with Checkboxes plugin for jQuery DataTables.

I was able to combine the two using the code below.

var table = $('#example').DataTable({
   'ajax': 'https://api.myjson.com/bins/1us28',
   'rowsGroup': [0,3],
   'columnDefs': [
      {
         'targets': 0,
         'data': 3,
         'checkboxes': {
            'selectRow': false
         }
      }
   ]
});   

See this example for code and demonstration.

HIGHLIGHTS

  • Row selection is disabled with 'selectRow': false as it doesn't behave as expected with row grouping.
  • Checkboxes use data for the fourth column 'data': 3.

LINKS

Upvotes: 3

Related Questions