Skip to content

Commit

Permalink
docs: add example with the searchPanes.cascadePanes feature
Browse files Browse the repository at this point in the history
By default, the item counters in the search panes are not updated if a
filter is applied.

Reference: https://datatables.net/reference/feature/searchPanes.cascadePanes
  • Loading branch information
darrachequesne committed Apr 3, 2024
1 parent 07b531c commit 4a9653b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,37 @@ $(document).ready(function() {
data : 'status'
}]
});
}
});
```
With the [`searchPanes.cascadePanes`](https://datatables.net/reference/feature/searchPanes.cascadePanes) feature:
```js
$(document).ready(function() {
var table = $('table#sample').DataTable({
ajax : '/data/users',
serverSide: true,
dom: 'Pfrtip',
columns : [{
data : 'id'
}, {
data : 'mail'
}, {
data : 'position',
searchPanes: {
show: true,
}
}, {
data : 'status',
searchPanes: {
show: true,
}
}],
searchPanes: {
cascadePanes: true,
},
});
});
```
Regarding the deserialization issue detailed [above](#step-6---fix-the-serialization--deserialization-of-the-query-parameters), here is the compatibility matrix:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ private SearchPanes computeSearchPanes(DataTablesInput input, Specification<T> s
this.entityManager.createQuery(query).getResultList().forEach(objects -> {
String value = String.valueOf(objects[0]);
long count = (long) objects[1];
// FIXME the number of items after filtering is the same as the total number of items, so the 'searchPanes.viewTotal'
// feature will not work properly. Fixing this would require two distinct queries, one with filtering and the other
// without. Reference: https://datatables.net/reference/feature/searchPanes.viewTotal
items.add(new SearchPanes.Item(value, value, count, count));
});

Expand Down

0 comments on commit 4a9653b

Please sign in to comment.