Angular UI Grid: How to create a pre-populated dropdown menu for column filtering

前端 未结 4 1685

I am looking for some help regarding a feature of the Angular UI Grid. Specifically I am exploring filtering and while I was able to succes

4条回答
  •  -上瘾入骨i
    2021-01-01 16:08

    An extension to the accepted answer is something I just discovered through trial and error. You can use regular expressions in the selectOptions:

               columnDefs: [
                {
                    name: 'starRating',
                    headerCellClass: 'blue',
                    headerTooltip: 'Star Rating',
                    maxWidth: 100, 
                    filter:
                    {
                        type: uiGridConstants.filter.SELECT,
                        selectOptions: [
                            { value: /(THREE|FOUR|FIVE)/, label: 'Positive' },  // Here I wanted the user to be able to choose one option that would filter by several of the possible values in the data set
                            { value: /(ONE|TWO)/, label: 'Negative' },  // ...and Here
                            { value: 'ONE', label: '1' },
                            { value: 'TWO', label: '2' },
                            { value: 'THREE', label: '3' },
                            { value: 'FOUR', label: '4' },
                            { value: 'FIVE', label: '5' }
                        ]
                    }
                },
    

提交回复
热议问题