reactabular-search-field
v6.0.0-readme-xZPNI
Published
Search field for Reactabular
Downloads
53
Maintainers
Readme
reactabular-search-field
provides a search field you can integrate to your Reactabular project.
How to Use?
Consider the example below.
Example:
/*
import React from 'react';
import {
Table, search, Search
} from 'reactabular';
*/
class SearchTable extends React.Component {
constructor(props) {
super(props);
this.state = {
searchColumn: 'all',
query: {}, // Search query
columns: [
{
property: 'name',
header: {
label: 'Name'
}
},
{
property: 'age',
header: {
label: 'Age'
}
}
],
rows: [
{
id: 100,
name: 'Adam',
age: 12
},
{
id: 101,
name: 'Brian',
age: 7
},
{
id: 102,
name: 'Jake',
age: 88
},
{
id: 103,
name: 'Jill',
age: 50
}
]
};
}
render() {
const { searchColumn, rows, columns, query } = this.state;
const searchedRows = search.multipleColumns({ columns, query })(rows);
return (
<div>
<div className="search-container">
<span>Search</span>
<Search
column={searchColumn}
query={query}
columns={columns}
rows={rows}
onColumnChange={searchColumn => this.setState({ searchColumn })}
onChange={query => this.setState({ query })}
/>
</div>
<Table.Provider columns={columns}>
<Table.Header />
<Table.Body rows={searchedRows} rowKey="id" />
</Table.Provider>
</div>
);
}
}
<SearchTable />