简体   繁体   中英

UIGrid (Angular JS) - having a dropdown in a table header column

I am using Angular 1.5 and am using the UI Grid. I was wondering is there a way to put a drop-down (ie a select) in a header column ? I know you can do it within the "data" cells/rows of the table but unsure if it can be done in the header title ?

See the below image link to see a visual of what I mean. I want to put the dropdown into the column header called "Value"

enter image description here

Thanks - Ronan.

You can specify a filter with selectOptions for displaying a dropdown in the header.

Example:

columnDefs: [{ 
              name: 'id', field: 'id'
            }, 
            { 
              name: 'value', field: 'value',
              filter: {
                       type: uiGridConstants.filter.SELECT,
                       selectOptions: [{ value: '1', label: 'One' }, 
                                       { value: '2', label: 'Two' }]
                      }
             }]

For more details check filter section in this link UI Grid ColumnDef - Filters

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM