Searching in table with rowGroup, can I show the entire group for any match
Searching in table with rowGroup, can I show the entire group for any match
I have a datatable that is using the rowGroup feature, and it is working for the most part exactly how I want with minimal effort.
I am listing a table of multi player games, grouped by table number. When I search for a player eg. "Fred" I want it to show the group, and all rows in the group, not just the search results. Right now It is showing the group and Fred, but it does not show the 3 other players on that table.
Any help for a point in the right direction would be great.
$('#table').DataTable( {
data: dataArray,
rowGroup: {
dataSrc : [1],
startRender : function (rows, group) {
return $('<tr/>').
append('<td colspan="3" class="text-center table-secondary text-dark h5">'+group+'</td>');
}
},
columnDefs: [
{ visible: false, targets: [1] }
],
lengthMenu: [[50, 100, -1], [50, 100, "All"]],
columns: [
{
title: "Player",
orderable: false,
},
{
title: "Table",
orderable: false
},
{
title: "Seat",
orderable: false
},
{
title: "Score",
orderable: false
}
],
"order": [[ 1, 'asc' ]]
} );
Answers
RowGroup just groups together rows with a common field. In your case, you've filtered those other three rows out of the table, so they're not there to group.
The only way I can think of doing it would be to create your own filter. When a string is entered, you call
filter()
to find the table that player is on, and then callsearch()
with that table number. That should work.Colin