@@ -9447,7 +9447,7 @@ var selectFilterTemplate = function (searchTerm, columnDef) {
94479447 columnDef.filter.selectOptions.forEach(function (option) {
94489448 options += "<option value=\"" + option.value + "\">" + option.label + "</option>";
94499449 });
9450- return "<select id=\"search-" + columnDef.id + "\" class=\"form-control\">" + options + "</select>";
9450+ return "<select class=\"form-control search-filter \">" + options + "</select>";
94519451};
94529452var FilterTemplates = {
94539453 input: inputFilterTemplate,
@@ -9617,8 +9617,8 @@ var Sorters = {
96179617 numeric: numericSorter,
96189618 string: stringSorter
96199619};
9620- var ControlPluginService = /** @class */ (function () {
9621- function ControlPluginService () {
9620+ var ControlAndPluginService = /** @class */ (function () {
9621+ function ControlAndPluginService () {
96229622 }
96239623 /**
96249624 * @param {?} grid
@@ -9627,7 +9627,9 @@ var ControlPluginService = /** @class */ (function () {
96279627 * @param {?} dataView
96289628 * @return {?}
96299629 */
9630- ControlPluginService.prototype.attachDifferentControlOrPlugins = function (grid, columnDefinitions, options, dataView) {
9630+ ControlAndPluginService.prototype.attachDifferentControlOrPlugins = function (grid, columnDefinitions, options, dataView) {
9631+ this._visibleColumns = columnDefinitions;
9632+ this._grid = grid;
96319633 if (options.enableColumnPicker) {
96329634 var /** @type {?} */ columnPickerControl = new Slick.Controls.ColumnPicker(columnDefinitions, grid, options);
96339635 }
@@ -9679,7 +9681,32 @@ var ControlPluginService = /** @class */ (function () {
96799681 }
96809682 }
96819683 };
9682- return ControlPluginService;
9684+ /**
9685+ * @param {?} column
9686+ * @return {?}
9687+ */
9688+ ControlAndPluginService.prototype.hideColumn = function (column) {
9689+ var /** @type {?} */ columnIndex = this._grid.getColumnIndex(column.id);
9690+ this._visibleColumns = this.removeColumnByIndex(this._visibleColumns, columnIndex);
9691+ this._grid.setColumns(this._visibleColumns);
9692+ };
9693+ /**
9694+ * @param {?} array
9695+ * @param {?} index
9696+ * @return {?}
9697+ */
9698+ ControlAndPluginService.prototype.removeColumnByIndex = function (array, index) {
9699+ return array.filter(function (el, i) {
9700+ return index !== i;
9701+ });
9702+ };
9703+ /**
9704+ * @return {?}
9705+ */
9706+ ControlAndPluginService.prototype.autoResizeColumns = function () {
9707+ this._grid.autosizeColumns();
9708+ };
9709+ return ControlAndPluginService;
96839710}());
96849711var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
96859712 return new (P || (P = Promise))(function (resolve, reject) {
@@ -9725,7 +9752,7 @@ var FilterService = /** @class */ (function () {
97259752 this.subscriber = new Slick.Event();
97269753 this.subscriber.subscribe(this.attachBackendOnFilterSubscribe);
97279754 grid.onHeaderRowCellRendered.subscribe(function (e, args) {
9728- _this.addFilterTemplateToHeaderRow();
9755+ _this.addFilterTemplateToHeaderRow(args );
97299756 });
97309757 };
97319758 /**
@@ -9766,6 +9793,27 @@ var FilterService = /** @class */ (function () {
97669793 });
97679794 });
97689795 };
9796+ /**
9797+ * Clear the search filters (below the column titles)
9798+ * @return {?}
9799+ */
9800+ FilterService.prototype.clearFilters = function () {
9801+ // remove the text inside each search input fields
9802+ jquery('.slick-headerrow-column .search-filter').val('');
9803+ // we need to loop through all columnFilters and delete them 1 by 1
9804+ // only trying to make columnFilter an empty (without looping) would not trigger a dataset change
9805+ for (var /** @type {?} */ columnId in this._columnFilters) {
9806+ if (columnId && this._columnFilters[columnId]) {
9807+ delete this._columnFilters[columnId];
9808+ }
9809+ }
9810+ // we also need to refresh the dataView and optionally the grid (it's optional since we use DataView)
9811+ if (this._dataView) {
9812+ this._dataView.refresh();
9813+ this._grid.invalidate();
9814+ this._grid.render();
9815+ }
9816+ };
97699817 /**
97709818 * @param {?} operator
97719819 * @param {?} value1
@@ -9805,7 +9853,7 @@ var FilterService = /** @class */ (function () {
98059853 }
98069854 });
98079855 grid.onHeaderRowCellRendered.subscribe(function (e, args) {
9808- _this.addFilterTemplateToHeaderRow();
9856+ _this.addFilterTemplateToHeaderRow(args );
98099857 });
98109858 };
98119859 /**
@@ -9890,9 +9938,10 @@ var FilterService = /** @class */ (function () {
98909938 }, e);
98919939 };
98929940 /**
9941+ * @param {?} args
98939942 * @return {?}
98949943 */
9895- FilterService.prototype.addFilterTemplateToHeaderRow = function () {
9944+ FilterService.prototype.addFilterTemplateToHeaderRow = function (args ) {
98969945 var _this = this;
98979946 var _loop_1 = function (i) {
98989947 if (this_1._columnDefinitions[i].id !== 'selector' && this_1._columnDefinitions[i].filterable) {
@@ -9914,12 +9963,17 @@ var FilterService = /** @class */ (function () {
99149963 filterTemplate = FilterTemplates.select(searchTerm, columnDef_1);
99159964 }
99169965 }
9966+ // when hiding/showing (Column Picker or Grid Menu), it will come re-create yet again the filters
9967+ // because of that we need to first get searchTerm from the columnFilters (that is what the user input last)
9968+ // if nothing is found, we can then use the optional searchTerm passed to the Grid Option (that is couple lines before)
9969+ var /** @type {?} */ inputSearchTerm = (this_1._columnFilters[columnDef_1.id]) ? this_1._columnFilters[columnDef_1.id].searchTerm : searchTerm || null;
99179970 // create the DOM Element
99189971 header = this_1._grid.getHeaderRowColumn(columnDef_1.id);
99199972 jquery(header).empty();
99209973 elm = jquery(filterTemplate);
9921- elm.val(searchTerm );
9974+ elm.attr('id', "filter-" + columnDef_1.id );
99229975 elm.data('columnId', columnDef_1.id);
9976+ elm.val(inputSearchTerm);
99239977 if (elm && typeof elm.appendTo === 'function') {
99249978 elm.appendTo(header);
99259979 }
@@ -32610,6 +32664,11 @@ var GlobalGridOptions = {
3261032664 enableTextSelectionOnCells: true,
3261132665 explicitInitialization: true,
3261232666 forceFitColumns: false,
32667+ gridMenu: {
32668+ columnTitle: 'Columns',
32669+ iconCssClass: 'fa fa-bars',
32670+ menuWidth: 16
32671+ },
3261332672 headerRowHeight: 35,
3261432673 multiColumnSort: true,
3261532674 pagination: {
@@ -32642,14 +32701,14 @@ var __awaiter$3 = (this && this.__awaiter) || function (thisArg, _arguments, P,
3264232701};
3264332702var AngularSlickgridComponent = /** @class */ (function () {
3264432703 /**
32645- * @param {?} controlPluginService
32704+ * @param {?} controlAndPluginService
3264632705 * @param {?} gridEventService
3264732706 * @param {?} filterService
3264832707 * @param {?} resizer
3264932708 * @param {?} sortService
3265032709 */
32651- function AngularSlickgridComponent(controlPluginService , gridEventService, filterService, resizer, sortService) {
32652- this.controlPluginService = controlPluginService ;
32710+ function AngularSlickgridComponent(controlAndPluginService , gridEventService, filterService, resizer, sortService) {
32711+ this.controlAndPluginService = controlAndPluginService ;
3265332712 this.gridEventService = gridEventService;
3265432713 this.filterService = filterService;
3265532714 this.resizer = resizer;
@@ -32695,7 +32754,7 @@ var AngularSlickgridComponent = /** @class */ (function () {
3269532754 this._dataView = new Slick.Data.DataView();
3269632755 this.grid = new Slick.Grid("#" + this.gridId, this._dataView, this.columnDefinitions, this._gridOptions);
3269732756 this.grid.setSelectionModel(new Slick.RowSelectionModel());
32698- this.controlPluginService .attachDifferentControlOrPlugins(this.grid, this.columnDefinitions, this._gridOptions, this._dataView);
32757+ this.controlAndPluginService .attachDifferentControlOrPlugins(this.grid, this.columnDefinitions, this._gridOptions, this._dataView);
3269932758 this.attachDifferentHooks(this.grid, this._gridOptions, this._dataView);
3270032759 // emit the Grid & DataView object to make them available in parent component
3270132760 this.gridChanged.emit(this.grid);
@@ -32847,7 +32906,7 @@ AngularSlickgridComponent.decorators = [
3284732906 * @nocollapse
3284832907 */
3284932908AngularSlickgridComponent.ctorParameters = function () { return [
32850- { type: ControlPluginService , },
32909+ { type: ControlAndPluginService , },
3285132910 { type: GridEventService, },
3285232911 { type: FilterService, },
3285332912 { type: ResizerService, },
@@ -32882,7 +32941,7 @@ AngularSlickgridModule.decorators = [
3288232941 SlickPaginationComponent
3288332942 ],
3288432943 providers: [
32885- ControlPluginService ,
32944+ ControlAndPluginService ,
3288632945 GraphqlService,
3288732946 GridEventService,
3288832947 OdataService,
@@ -32899,5 +32958,5 @@ AngularSlickgridModule.ctorParameters = function () { return []; };
3289932958/**
3290032959 * Generated bundle index. Do not edit.
3290132960 */
32902- export { CaseType, FieldType, FormElementType, KeyCode, OperatorType, SortDirection, Editors, FilterConditions, FilterTemplates, Formatters, Sorters, ControlPluginService , FilterService, GridEventService, GraphqlService, GridExtraUtils, GridOdataService, ResizerService, SortService, SlickPaginationComponent, AngularSlickgridComponent, AngularSlickgridModule, ControlPluginService as ɵb, FilterService as ɵd, GridEventService as ɵc, ResizerService as ɵe, SortService as ɵf, OdataService as ɵa };
32961+ export { CaseType, FieldType, FormElementType, KeyCode, OperatorType, SortDirection, Editors, FilterConditions, FilterTemplates, Formatters, Sorters, ControlAndPluginService , FilterService, GridEventService, GraphqlService, GridExtraUtils, GridOdataService, ResizerService, SortService, SlickPaginationComponent, AngularSlickgridComponent, AngularSlickgridModule, ControlAndPluginService as ɵb, FilterService as ɵd, GridEventService as ɵc, ResizerService as ɵe, SortService as ɵf, OdataService as ɵa };
3290332962//# sourceMappingURL=angular-slickgrid.es5.js.map
0 commit comments