Skip to content

Instantly share code, notes, and snippets.

@irzhywau
Created June 21, 2019 16:08
Show Gist options
  • Save irzhywau/89cc85a473a010320423eb5037a97a4b to your computer and use it in GitHub Desktop.
Save irzhywau/89cc85a473a010320423eb5037a97a4b to your computer and use it in GitHub Desktop.
Rendering table on front
render() {
//change to let
let {columns, fields, cache, element_id} = this.props;
let {data, pages, loading, error} = this.state;
// get user session, unique for each browser
let sessionId = getPHPSessId();
const Error = ({error}) => (
<span style={{fontSize: "120%", color:"#ff0000", width:"100%", textAlign:"center", display:"inline-block"}}>Oops!! {error}</span>
);
return (
<div className="table-ctn">
{
error ? (
<Error error={error}/>
) : null
}
<ReactTable
columns={columns(data)}
loadingText={<LoadingComponent ref={progress => this.progress = progress} progress={0}/>}
manual
data={data}
onFilteredChange={this.handleFilteredChange}
pages={pages}
loading={loading}
onFetchData={_.debounce(this.fetchData)}
filterable
defaultPageSize={cache.recursive([sessionId, 'size'].join('/'), 5)}
defaultSorted={cache.recursive([sessionId, element_id, 'sorted'].join('/'))}
defaultFiltered={cache.recursive([sessionId, element_id, 'filtered'].join('/'))}
showPageSizeOptions={true}
pageSizeOptions={[5, 10, 20, 25, 50, 100]}
className="-highlight"
/>
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment