material-table icon indicating copy to clipboard operation
material-table copied to clipboard

I want to show the filters in the same row along with column headers and not as a separate header. Let me know how to achieve this.

Open vijthang61 opened this issue 7 years ago • 4 comments

I am requesting this to avoid duplicating same code again while overriding components

vijthang61 avatar Feb 19 '19 10:02 vijthang61

@vijthang61 ,

This is not a easy change. You should develop your own header component that handles every feature of default header and default filter row.

But i don't know what you exactly want? Can you show me an example? such as another datatable

mbrn avatar Feb 19 '19 12:02 mbrn

image

I want to have filters on same line as column header in this image

vijthang61 avatar Feb 19 '19 13:02 vijthang61

I managed to get the filter on same line by setting the title

Whatever value i display in title that i had modified by creating custom function

renderColumnHeader = (title,field,lookup) => { return( <div style={{display:"flex"}}>

{title}
{lookup===undefined &&} {lookup && <FormControl style={{ width: '100%' }}> <Select multiple value={this.state.filter || []} onChange={this.onFilterChanged} input={} renderValue={selecteds => selecteds.map(selected => lookup[selected]).join(', ')} MenuProps={MenuProps} > { Object.keys(lookup).map(key => ( <Checkbox checked={this.state.filter && this.state.filter.indexOf(key.toString()) > -1} /> )) } }
); }

But the problem is since the columns are sortable, when I click on the filter field it first applies sort, so now the complication is to sort only when clicked on header name and not the filter field.

vijthang61 avatar Feb 19 '19 13:02 vijthang61

You may implement your own header component. So you can handle all events and manage them according to your project.

mbrn avatar Feb 20 '19 18:02 mbrn