react-tabulator icon indicating copy to clipboard operation
react-tabulator copied to clipboard

bug: validate is not called when updating data

Open lcaouen opened this issue 4 years ago • 2 comments

ReactTabulator never calls "table.validate()" when data are loaded or changed. We have to do it manually, using the ref : this.state.tableRef.table.validate() Could add the validate when loading or changing the data ?

lcaouen avatar Jan 21 '21 14:01 lcaouen

I'm not aware of validate(). Is this a common use case? It'd be helpful to understand if you have a Codesandbox link and example. Thanks.

ngduc avatar Jan 23 '21 16:01 ngduc

Here is the documentation : http://tabulator.info/docs/4.9/validate#manual

We use custom validators. Every time we update the data, we have to force table.redraw() and table.validate() to get the data validation. Would be nice if it could be done autmatically when the props.data changes

dataLoaded = () => {
    this.state.tableRef.table.redraw()
    this.validateTable()
  }

  validateTable = () => {
    if(this.state.tableRef && this.state.tableRef.table){
      this.state.tableRef.table.validate()
    }
  }

render() {
    return (
      <div className={Style.StoreTable}>
        <ReactTabulator
          ref={this.setTable}
          options={this.options}
          columns = {this.state.columns}
          data= {this.state.data}
          rowFormatter={this.rowValidator}
          rowSelected={this.rowSelected}
          rowClick={this.rowClick}
          dataChanged={this.dataLoaded}
          dataLoaded={this.dataLoaded}
          initialSort={[{column: 'valid', dir: 'asc'}]}/>
      </div>
    )
  }

lcaouen avatar Jan 24 '21 13:01 lcaouen