My grid isn’t recognizing individual column filter adjustments, either changing the operator or the filterType.
html
[toolbar]='toolbarOptions' [allowGrouping]='true' (queryCellInfo)='queryCellInfo($event)'
[allowExcelExport]='true' (toolbarClick)='toolbarClick($event)' [allowFiltering]='true'
[showColumnChooser]= 'true'
allowTextWrap='true' [textWrapSettings]='wrapSettings' [allowSorting]="true"
[columns]='columns'>
ts
public grid: GridComponent; dataBound() {
Object.assign((this.grid.filterModule as any).filterOperators, { startsWith: 'contains' }); //if I turn this off, everything defaults to equal and it doesn’t respond to individual columns = contains
var grid: GridComponent = this.grid;
public filter: IFilter; //I’ve also tried these as ‘any’
public colfilter: IFilter;
OnInit
this.filter = {
type: 'Menu'
};
this.colfilter= { operator: "equal" },
//I’ve tried setting ‘equal’ two different ways. In the Screen shot, you can see both are contains. And the menu doesn’t show
this.columns = [
{field: 'requirementType',filter:'colfilter',visible:false ,matchCase: false, headerText:'Type', textAlign:'Center', width: 160},
{field: 'threatCategory', operator: 'equal' ,matchCase: false, headerText:'Threat Category', textAlign:'Center',width: 180},
{field: 'isActive', filter:'filter' ,headerText:'In Use', textAlign:'Center',template: this.checkboxCol,editType:'booleanedit',width: 80} ….
So what am I missing?
Thanks
Attachment: FilterBar_beda638d.zip
since I can't solve mixing operator types,
Trying a different approach. I’ve stripped this all down. I just want one filter bar and one checkbox.
If I omit filterSettings, I get a standard two-columns with filter bars, even though I declare filter types in the columns.
<ejs-grid [dataSource]='requirements' [allowFiltering]='true' [filterSettings]='filterOptions' height='273px' width='500px'>
<e-columns>
<e-column field= 'name' [filter] = 'filterBar' headerText='Requirement' textAlign='Center' width= 160></e-column>
<e-column field='requirementType' [filter] = 'filter' headerText='type' textAlign='Center' width=100></e-column>
</e-columns>
</ejs-grid>
public filter: IFilter;
public filterBar: IFilter;
this.filterOptions = {type: 'Menu'};
this.filter = {type: 'CheckBox'};
this.filterBar = {type: 'FilterBar'};
If I turn on filterOptions, it gives me a menu and a checkbox. So it’s closer. Here if I set filterOptions = ‘FilterBar’, the checkbox goes away and is just a filterbar.
<ejs-grid [dataSource]='requirements' [allowFiltering]='true' [filterSettings]='filterOptions' height='273px' width='500px'>
<e-columns>
<e-column field= 'name' headerText='Requirement' textAlign='Center' width= 160></e-column>
<e-column field='requirementType' [filter] = 'filter' headerText='type' textAlign='Center' width=100></e-column>
</e-columns>
</ejs-grid>
<ejs-grid [dataSource]='requirements' [allowFiltering]='true' [filterSettings]='filterOptions' height='273px' width='500px'>
<e-columns>
<e-column field= 'name' [filter] = 'filterBar' headerText=’Some name’ textAlign='Center' width= 160></e-column>
<e-column field='requirementType' [filter] = 'filter' headerText='type' textAlign='Center' width=100></e-column>
</e-columns>
</ejs-grid>
So I tried overriding the 1st column with a filterbar
But that kicks out an error
this.type[type] is not a constructor
at
How do I mix a filterbar and a checkbox?
If it can't be done, that takes me back to my original problem.
How do I make one of those columns 'equal' and one 'contains' as I can't get that to work either.
Thanks!
|
// Grid’s actionBegin event handler
onActionBegin(args) {
// Check if the required column is getting filtered
if (args.requestType === "filtering" && args.currentFilteringColumn === "ShipCountry") {
// Filter operator is changed for the required column in the filter columns model
args.columns.forEach(col => {
if (col.field === "ShipCountry")
col.operator = "contains"
})
}
} |
that's disappointing I can't mix filterBar and a checkbox but that's just the way it is.
As to having one column equals and one column contains, that seems an awfully complicated way to do that. But ok, I'll give it a go. Thanks!
It works, so I'll go with that.
Thanks for your support.
Good job.