6.0.0 • Published 9 years ago
reactabular-highlight v6.0.0
To make it possible to highlight search results per column, there's a specific highlight.cell formatter.
How to Use?
To use it, you'll first you have to annotate your rows using highlight.highlighter. It attaches a structure like this there:
_highlights: {
demo: [{ startIndex: 0, length: 4 }]
}Example:
/*
import React from 'react';
import { compose } from 'redux';
import {
Table, search, Search, highlight
} from 'reactabular';
*/
class HighlightTable extends React.Component {
constructor(props) {
super(props);
this.state = {
query: {},
columns: [
{
property: 'name',
header: {
label: 'Name'
},
cell: {
format: highlight.cell
}
},
{
property: 'age',
header: {
label: 'Age'
},
cell: {
format: highlight.cell
}
}
],
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 { rows, columns, query } = this.state;
const filteredRows = compose(
highlight.highlighter({ columns, matches: search.matches, query }),
search.multipleColumns({ columns, query })
)(rows);
return (
<div>
<div className="search-container">
<span>Search</span>
<Search
query={query}
columns={columns}
rows={rows}
onChange={query => this.setState({ query })}
/>
</div>
<Table.Provider columns={columns}>
<Table.Header />
<Table.Body rows={filteredRows} rowKey="id" />
</Table.Provider>
</div>
);
}
}
<HighlightTable />6.0.0-readme-vYigF
9 years ago
6.0.0
9 years ago
3.0.0
10 years ago
2.0.5-alpha.331d29a6
10 years ago
2.0.5-alpha.f20b57cb
10 years ago
2.0.1
10 years ago
2.0.0
10 years ago
1.2.6-alpha.61e29539
10 years ago
1.2.5
10 years ago
1.2.3
10 years ago
1.1.0
10 years ago
1.0.9
10 years ago
1.0.6
10 years ago
1.0.5
10 years ago
1.0.4
10 years ago
1.0.2
10 years ago
1.0.1
10 years ago
1.0.0
10 years ago
0.1.0
10 years ago