0

Griddle version=^0.2.13

Expected Behavior

I am using customHeaderComponent to render columns wise filter on the table that I am displaying but when i run the code filter is not getting rendered.

App.jsx



import React, { Component } from 'react';
    import Griddle from 'griddle-react';

    import HeaderComponent from 'components/HeaderComponent';


    export default class App extends Component {

       constructor(props) {
          super(props);
          this.state = { 
               colData: [{
                         "columnName": "nodeId",
                         "order": 1,
                         "displayName": "Warehouse",
                         "customHeaderComponent": HeaderComponent
                        },
                        {
                         "columnName": "nodeType",
                         "order": 2,
                         "displayName": "Node Type"
                        },
                        {
                         "columnName": "backlog",
                         "order": 3,
                         "displayName": "Backlog"
                        },
                        {
                         "columnName": "ptmPad",
                         "order": 4,
                         "displayName": "PTM Pad"
                        }]
             };
         }    

       render() {
         return (
         <div>
               <Griddle ref='Griddle' results={this.props.data} tableClassName="table" showFilter={true} useFixedHeader={true} resultsPerPage={20} filterPlaceholderText="Search"
                 columnMetadata = {this.state.colData}
                 showSettings={true}  />
         </div>
       );  
     } 
    }

HeaderComponent.jsx

import React, { Component } from 'react';


export default class HeaderComponent extends Component {
  constructor(props) {
        super(props);

        this.textOnClick = this.textOnClick.bind(this);
        this.filterText = this.filterText.bind(this);
 }       

  textOnClick(e) {
     e.stopPropagation();
  }

  filterText(e) {
    this.props.filterByColumn(e.target.value, this.props.columnName);
  }

  render(){
    return (
      <span>
        <input type='text' onChange={this.filterText} onClick={this.textOnClick} />
      </span>
    );
  }

}

I am stuck on this since very long. Is this customHeaderComponent feature not available in this version? If yes what is the way to implement column level filtering

styrofoam fly
  • 578
  • 2
  • 9
  • 25
Hemanshu Sethi
  • 139
  • 1
  • 1
  • 7
  • I am not sure, but on change needs you to leave from the input to execute the function, you might want to use onKeyUp ? – Arnaud Rochez Oct 27 '17 at 11:14
  • Thanks for your reply but in this case the render function for HeaderComponent is not getting called. That's why I asked whether this feature of customHeaderComponent is present in the mentioned version of Griddle or not? because my code compiles without any error but I don't see any column level filters added to the UI. – Hemanshu Sethi Oct 31 '17 at 11:19
  • Can anyone reply to this question? Need help here – Hemanshu Sethi Nov 08 '17 at 10:33

0 Answers0