Add 'Default Filters' and 'Clear Filters' buttons to new grid filters form.
This commit is contained in:
parent
d2b065a8fc
commit
d57f5169b0
4 changed files with 39 additions and 1 deletions
25
tailbone/static/js/jquery.ui.tailbone.js
vendored
25
tailbone/static/js/jquery.ui.tailbone.js
vendored
|
@ -19,11 +19,15 @@
|
|||
this.filters = this.element.find('.newfilters');
|
||||
this.add_filter = this.filters.find('#add-filter');
|
||||
this.apply_filters = this.filters.find('#apply-filters');
|
||||
this.default_filters = this.filters.find('#default-filters');
|
||||
this.clear_filters = this.filters.find('#clear-filters');
|
||||
this.grid = this.element.find('.newgrid');
|
||||
|
||||
// Enhance filters etc.
|
||||
this.filters.find('.filter').gridfilter();
|
||||
this.apply_filters.button('option', 'icons', {primary: 'ui-icon-search'});
|
||||
this.default_filters.button('option', 'icons', {primary: 'ui-icon-home'});
|
||||
this.clear_filters.button('option', 'icons', {primary: 'ui-icon-trash'});
|
||||
if (! this.filters.find('.active:checked').length) {
|
||||
this.apply_filters.button('disable');
|
||||
}
|
||||
|
@ -79,6 +83,27 @@
|
|||
return false;
|
||||
});
|
||||
|
||||
// When user clicks Default Filters button, refresh page with
|
||||
// instructions for the server to reset filters to default settings.
|
||||
this.default_filters.click(function() {
|
||||
var form = that.filters.find('form');
|
||||
form.off('submit');
|
||||
form.append('<input type="hidden" name="reset-to-default-filters" value="true" />');
|
||||
that.element.mask("Refreshing data...");
|
||||
form.submit();
|
||||
});
|
||||
|
||||
// When user clicks Clear Filters button, deactivate all filters
|
||||
// and refresh the grid.
|
||||
this.clear_filters.click(function() {
|
||||
that.filters.find('.filter').each(function() {
|
||||
if ($(this).gridfilter('active')) {
|
||||
$(this).gridfilter('active', false);
|
||||
}
|
||||
});
|
||||
that.filters.find('form').submit();
|
||||
});
|
||||
|
||||
// Refresh data when user clicks a sortable column header.
|
||||
this.element.on('click', 'thead th.sortable a', function() {
|
||||
var th = $(this).parent();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue