forked from SummitRoute/react-structured-filter
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathExampleTable.jsx
More file actions
99 lines (84 loc) · 2.63 KB
/
ExampleTable.jsx
File metadata and controls
99 lines (84 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
var React = require('react');
var Griddle = require('griddle-react');
var GriddleWithCallback = require('./GriddleWithCallback');
var StructuredFilter = require('../../src/main');
require('../../src/react-structured-filter.css');
var ExampleData = require('./ExampleData');
var ExampleTable = React.createClass({
getInitialState: function() {
return {
filter: [
{
category: 'Industry',
operator: '==',
value: 'Music',
},
{
category: 'IPO',
operator: '>',
value: 'Dec 8, 1980 10:50 PM',
},
],
header: {
first: "Category1",
second: "Operator1",
third: "Value1"
},
}
},
getJsonData: function(filterString, sortColumn, sortAscending, page, pageSize, callback) {
if (filterString==undefined) {
filterString = "";
}
if (sortColumn==undefined) {
sortColumn = "";
}
// Normally you would make a Reqwest here to the server
var results = ExampleData.filter(filterString, sortColumn, sortAscending, page, pageSize);
callback(results);
},
updateFilter: function(filter){
// Set our filter to json data of the current filter tokens
this.setState({filter: filter});
},
getSymbolOptions: function() {
return ExampleData.getSymbolOptions();
},
getSectorOptions: function() {
return ExampleData.getSectorOptions();
},
getIndustryOptions: function() {
return ExampleData.getIndustryOptions();
},
render: function(){
return (
<div>
<StructuredFilter
placeholder="Filter data..."
options={[
{category:"Symbol", type:"textoptions", options:this.getSymbolOptions},
{category:"Name",type:"text"},
{category:"Price",type:"number"},
{category:"MarketCap",type:"number"},
{category:"IPO", type:"date"},
{category:"Sector", type:"textoptions", options:this.getSectorOptions},
{category:"Industry", type:"textoptions", options:this.getIndustryOptions}
]}
customClasses={{
input: "filter-tokenizer-text-input",
results: "filter-tokenizer-list__container",
listItem: "filter-tokenizer-list__item"
}}
onChange={this.updateFilter}
value={this.state.filter}
header={this.state.header}
/>
<GriddleWithCallback
getExternalResults={this.getJsonData} filter={JSON.stringify(this.state.filter)}
resultsPerPage={10}
/>
</div>
)
}
});
module.exports = ExampleTable;