Can we just replace input field of filter component to a material UI text field

1.3k views Asked by At

I am trying to replace filter components input field with text field from materialUI text field. I am able to display input field by creating a new component, but its not filtering contents.

I don't want different filter function just wanted to replace input field with material UI text field

Current Griddle section is

import Pagination from '/imports/ui/components/admin/common/pagination-new'; import Filteration from '/imports/ui/components/admin/common/filteration-new';

    <Griddle
      ref={(ref) => {this._griddle = ref}}
      useGriddleStyles={false}
      columnMetadata={columnMeta}
      results={this.getGriddleData()}
      resultsPerPage={5}
      tableClassName='table'
      showFilter={true}
      settingsText={''}
      showSettings={true}
      settingsToggleClassName={'text-hide'}
      settingsIconComponent={
        <RaisedButton
          label='Columns'
          primary={true}
        />}
      useCustomPagerComponent={true}
      customPagerComponent={Pagination}
      useCustomFilterComponent={true}
      customFilterComponent={Filteration}
      columns={[
        'actions','name', 'published', 'whiteboard.exist',
        'location.floor', 'capacity.number',
        'av.tv','av.appleTv','av.videocon',]}/>

Filteration Component

  render() {
    return (
      <div style={{display: 'flex'}}>
          <TextField
            name='title'
            floatingLabelText='title'
          />
      </div>
    )
  },
1

There are 1 answers

0
Jeff McCloud On BEST ANSWER

Yes, this can be done. The component you supply to customFilterComponent will receive the following props from Griddle: changeFilter, results, currentResults, placeholderText. You can then reference these inside that component, and pass them onto the material-ui TextField:

render() {
    const { changeFilter, results, currentResults, placeholderText } = this.props;

    return (
        <div style={{ display: 'flex' }}>
            <TextField
                onChange={(e, value) => changeFilter(value)}
                name='title'
                floatingLabelText={placeholderText}
            />
        </div>
    )
}