Skip to content

Commit

Permalink
Added dynamic filter details div displaying current active search set…
Browse files Browse the repository at this point in the history
…tings
  • Loading branch information
Eitan Blumin committed Apr 6, 2019
1 parent a682e57 commit 95f3976
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions src/AdminLTE/datatable_respite_crud.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,6 @@ class respite_crud {
if (data != '' && data != undefined && ed != undefined && ed['options'] != undefined) {

var opList = ed.options;
console.log('rendering bitwise:');
console.log(ed.options);

for (var i = 0; i < opList.length; i++) {

Expand Down Expand Up @@ -1556,7 +1554,7 @@ class respite_crud {
"searchDelay": 700,

//// DOM setting: //// more info here: https://datatables.net/reference/option/dom
"dom": "Bilfpr<'table-responsive't>p", // TODO: the B section should only be added if toolbar buttons were added
"dom": "Bil<'dt-dynamic-filter-details'>fpr<'table-responsive't>p", // TODO: the B section should only be added if toolbar buttons were added

//// Custom Buttons: ////
"buttons": {
Expand Down Expand Up @@ -1700,6 +1698,32 @@ class respite_crud {
if (respite_crud.isDetailRowsAdded) {
// On each draw, loop over the `detailRows` array and show any child rows
respite_crud.dt.on('draw', function () {
//dt-dynamic-filter-details
$('body').find('.dt-dynamic-filter-details').empty();
var searchCols = respite_crud.dt.settings()[0].aoPreSearchCols; //setOptions.searchCols;
for (var i = 0; i < searchCols.length; i++) {
if (searchCols[i]['sSearch']) {
var col = setOptions.columns[i];
var grp = $('<div class="btn-group" role="group"></div>');
var meta = {
"settings": { "aoColumns": respite_crud.dt.settings()[0].aoColumns },
"col": i
};

grp
.append($('<button type="button" class="btn btn-primary"></button>').text(col['editor_data']['label'] || col['name']))
.append($('<button type="button" class="btn btn-default"><i class="fas fa-filter"></i></button>'))
.append($('<button type="button" class="btn btn-secondary"></button>').text(
col.mRender(searchCols[i]['sSearch'], undefined, undefined, meta)
|| searchCols[i]['sSearch'])
)
.append($('<button type="button" class="btn btn-primary"><i class="fas fa-times"></i></button>'))
;

$('body').find('.dt-dynamic-filter-details').append(grp.clone());
}
}

$.each(respite_crud.detailRows, function (i, id) {
$('#' + id + ' td a.details-control').trigger('click');
});
Expand Down

1 comment on commit 95f3976

@EitanBlumin
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partial Implementation of #103

Please sign in to comment.