@@ -72,7 +72,7 @@ <h2 id="usage">Usage</h2>
72
72
73
73
< p > The simplest example:</ p >
74
74
75
- < div > < div class ="CodeRay ">
75
+ < div class =" highlighter-coderay " > < div class ="CodeRay ">
76
76
< div class ="code "> < pre > < span class ="line-numbers "> < a href ="#n1 " name ="n1 "> 1</ a > </ span > < span style ="color:#080;font-weight:bold "> var</ span > Table = Reactable.Table;
77
77
< span class ="line-numbers "> < a href ="#n2 " name ="n2 "> 2</ a > </ span > React.renderComponent(
78
78
< span class ="line-numbers "> < a href ="#n3 " name ="n3 "> 3</ a > </ span > < span style ="color:#070;font-weight:bold "> <Table</ span > < span style ="color:#b48 "> className</ span > =< span style ="background-color:hsla(0,100%,50%,0.05) "> < span style ="color:#710 "> "</ span > < span style ="color:#D20 "> table</ span > < span style ="color:#710 "> "</ span > </ span > < span style ="color:#b48 "> data</ span > =< span style ="color:#F00;background-color:#FAA "> {</ span > < span style ="color:#F00;background-color:#FAA "> [</ span >
@@ -98,7 +98,7 @@ <h3 id="further-customization">Further Customization</h3>
98
98
This approach can be freely combined with the < code > data</ code > property on the < code > <Table></ code > ,
99
99
and is useful if you want to specify per-row attributes such as classes, like so:</ p >
100
100
101
- < div > < div class ="CodeRay ">
101
+ < div class =" highlighter-coderay " > < div class ="CodeRay ">
102
102
< div class ="code "> < pre > < span class ="line-numbers "> < a href ="#n1 " name ="n1 "> 1</ a > </ span > < span style ="color:#080;font-weight:bold "> var</ span > Table = Reactable.Table,
103
103
< span class ="line-numbers "> < a href ="#n2 " name ="n2 "> 2</ a > </ span > Tr = Reactable.Tr;
104
104
< span class ="line-numbers "> < a href ="#n3 " name ="n3 "> 3</ a > </ span >
@@ -126,7 +126,7 @@ <h3 id="even-more-customization">Even More Customization</h3>
126
126
127
127
< p > Example:</ p >
128
128
129
- < div > < div class ="CodeRay ">
129
+ < div class =" highlighter-coderay " > < div class ="CodeRay ">
130
130
< div class ="code "> < pre > < span class ="line-numbers "> < a href ="#n1 " name ="n1 "> 1</ a > </ span > < span style ="color:#080;font-weight:bold "> var</ span > Table = Reactable.Table,
131
131
< span class ="line-numbers "> < a href ="#n2 " name ="n2 "> 2</ a > </ span > Tr = Reactable.Tr,
132
132
< span class ="line-numbers "> < a href ="#n3 " name ="n3 "> 3</ a > </ span > Td = Reactable.Td;
@@ -172,32 +172,35 @@ <h3 id="preventing-escaping-of-html">Preventing escaping of HTML</h3>
172
172
173
173
< p > If you don’t want to go all the way down the JSX rabbit hole to render individual cells as
174
174
HTML, and you know your source data is safe, you can wrap strings in < code > Reactable.unsafe</ code > to
175
- prevent their content from being escaped, like so:
176
- ~~~javascript
177
- var Table = Reactable.Table,
178
- unsafe = Reactable.unsafe;</ p >
179
-
180
- < p > React.renderComponent(
181
- <Table className=”table” id=”table” data={[
182
- {
183
- ‘Name’: unsafe(‘< b > Griffin Smith</ b > ’),
184
- ‘Github’: unsafe(‘< a href ="https://github.com/glittershark "> < img src ="https://d2k1ftgv7pobq7.cloudfront.net/images/services/8cab38550d1f23032facde191031d024/github.png " /> </ a > ’)
185
- },
186
- {
187
- ‘Name’: unsafe(‘< b > Ian Zhang</ b > ’),
188
- ‘Github’: unsafe(‘< a href ="https://github.com/lofiinterstate "> < img src ="https://d2k1ftgv7pobq7.cloudfront.net/images/services/8cab38550d1f23032facde191031d024/github.png " /> </ a > ’)
189
- },
190
- ]}/>,
191
- document.getElementById(‘table’)
192
- );
193
- ~~~</ p >
175
+ prevent their content from being escaped, like so:</ p >
176
+
177
+ < div class ="highlighter-coderay "> < div class ="CodeRay ">
178
+ < div class ="code "> < pre > < span class ="line-numbers "> < a href ="#n1 " name ="n1 "> 1</ a > </ span > < span style ="color:#080;font-weight:bold "> var</ span > Table = Reactable.Table,
179
+ < span class ="line-numbers "> < a href ="#n2 " name ="n2 "> 2</ a > </ span > unsafe = Reactable.unsafe;
180
+ < span class ="line-numbers "> < a href ="#n3 " name ="n3 "> 3</ a > </ span >
181
+ < span class ="line-numbers "> < a href ="#n4 " name ="n4 "> 4</ a > </ span > React.renderComponent(
182
+ < span class ="line-numbers "> < a href ="#n5 " name ="n5 "> 5</ a > </ span > <Table className=< span style ="background-color:hsla(0,100%,50%,0.05) "> < span style ="color:#710 "> "</ span > < span style ="color:#D20 "> table</ span > < span style ="color:#710 "> "</ span > </ span > id=< span style ="background-color:hsla(0,100%,50%,0.05) "> < span style ="color:#710 "> "</ span > < span style ="color:#D20 "> table</ span > < span style ="color:#710 "> "</ span > </ span > data={[
183
+ < span class ="line-numbers "> < a href ="#n6 " name ="n6 "> 6</ a > </ span > {
184
+ < span class ="line-numbers "> < a href ="#n7 " name ="n7 "> 7</ a > </ span > < span style ="color:#606 "> < span style ="color:#404 "> '</ span > < span > Name</ span > < span style ="color:#404 "> '</ span > </ span > : unsafe(< span style ="background-color:hsla(0,100%,50%,0.05) "> < span style ="color:#710 "> '</ span > < span style ="color:#D20 "> <b>Griffin Smith</b></ span > < span style ="color:#710 "> '</ span > </ span > ),
185
+ < span class ="line-numbers "> < a href ="#n8 " name ="n8 "> 8</ a > </ span > < span style ="color:#606 "> < span style ="color:#404 "> '</ span > < span > Github</ span > < span style ="color:#404 "> '</ span > </ span > : unsafe(< span style ="background-color:hsla(0,100%,50%,0.05) "> < span style ="color:#710 "> '</ span > < span style ="color:#D20 "> <a href="https://github.com/glittershark"><img src="https://d2k1ftgv7pobq7.cloudfront.net/images/services/8cab38550d1f23032facde191031d024/github.png"></a></ span > < span style ="color:#710 "> '</ span > </ span > )
186
+ < span class ="line-numbers "> < a href ="#n9 " name ="n9 "> 9</ a > </ span > },
187
+ < span class ="line-numbers "> < strong > < a href ="#n10 " name ="n10 "> 10</ a > </ strong > </ span > {
188
+ < span class ="line-numbers "> < a href ="#n11 " name ="n11 "> 11</ a > </ span > < span style ="color:#606 "> < span style ="color:#404 "> '</ span > < span > Name</ span > < span style ="color:#404 "> '</ span > </ span > : unsafe(< span style ="background-color:hsla(0,100%,50%,0.05) "> < span style ="color:#710 "> '</ span > < span style ="color:#D20 "> <b>Ian Zhang</b></ span > < span style ="color:#710 "> '</ span > </ span > ),
189
+ < span class ="line-numbers "> < a href ="#n12 " name ="n12 "> 12</ a > </ span > < span style ="color:#606 "> < span style ="color:#404 "> '</ span > < span > Github</ span > < span style ="color:#404 "> '</ span > </ span > : unsafe(< span style ="background-color:hsla(0,100%,50%,0.05) "> < span style ="color:#710 "> '</ span > < span style ="color:#D20 "> <a href="https://github.com/lofiinterstate"><img src="https://d2k1ftgv7pobq7.cloudfront.net/images/services/8cab38550d1f23032facde191031d024/github.png"></a></ span > < span style ="color:#710 "> '</ span > </ span > )
190
+ < span class ="line-numbers "> < a href ="#n13 " name ="n13 "> 13</ a > </ span > },
191
+ < span class ="line-numbers "> < a href ="#n14 " name ="n14 "> 14</ a > </ span > ]}/>,
192
+ < span class ="line-numbers "> < a href ="#n15 " name ="n15 "> 15</ a > </ span > document.getElementById(< span style ="background-color:hsla(0,100%,50%,0.05) "> < span style ="color:#710 "> '</ span > < span style ="color:#D20 "> table</ span > < span style ="color:#710 "> '</ span > </ span > )
193
+ < span class ="line-numbers "> < a href ="#n16 " name ="n16 "> 16</ a > </ span > );
194
+ </ pre > </ div >
195
+ </ div >
196
+ </ div >
194
197
195
198
< h3 id ="pagination "> Pagination</ h3 >
196
199
197
200
< p > You can also use pagination, by just specifying an < code > itemsPerPage</ code > argument to the
198
201
< code > <Table></ code > component. For example:</ p >
199
202
200
- < div > < div class ="CodeRay ">
203
+ < div class =" highlighter-coderay " > < div class ="CodeRay ">
201
204
< div class ="code "> < pre > < span class ="line-numbers "> < a href ="#n1 " name ="n1 "> 1</ a > </ span > < span style ="color:#070;font-weight:bold "> <Table</ span > < span style ="color:#b48 "> className</ span > =< span style ="background-color:hsla(0,100%,50%,0.05) "> < span style ="color:#710 "> "</ span > < span style ="color:#D20 "> table</ span > < span style ="color:#710 "> "</ span > </ span > < span style ="color:#b48 "> data</ span > =< span style ="color:#F00;background-color:#FAA "> {</ span > < span style ="color:#F00;background-color:#FAA "> [</ span >
202
205
< span class ="line-numbers "> < a href ="#n2 " name ="n2 "> 2</ a > </ span > < span style ="color:#F00;background-color:#FAA "> {</ span > < span style ="color:#700 "> Name:</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#b48 "> Griffin</ span > < span style ="color:#b48 "> Smith</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#F00;background-color:#FAA "> ,</ span > < span style ="color:#b48 "> Age:</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#b48 "> 18</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#F00;background-color:#FAA "> }</ span > < span style ="color:#F00;background-color:#FAA "> ,</ span >
203
206
< span class ="line-numbers "> < a href ="#n3 " name ="n3 "> 3</ a > </ span > < span style ="color:#F00;background-color:#FAA "> {</ span > < span style ="color:#b48 "> Age:</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#b48 "> 23</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#F00;background-color:#FAA "> ,</ span > < span style ="color:#b48 "> Name:</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#b48 "> Lee</ span > < span style ="color:#b48 "> Salminen</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#F00;background-color:#FAA "> }</ span > < span style ="color:#F00;background-color:#FAA "> ,</ span >
@@ -230,9 +233,8 @@ <h3 id="sorting">Sorting</h3>
230
233
231
234
< p > To specify a custom sort function, use the following structure for the column object:</ p >
232
235
233
- < div > < div class ="CodeRay ">
234
- < div class ="code "> < pre > < span class ="line-numbers "> < a href ="#n1 " name ="n1 "> 1</ a > </ span >
235
- < span class ="line-numbers "> < a href ="#n2 " name ="n2 "> 2</ a > </ span > {< span style ="color:#606 "> column</ span > : < span style ="background-color:hsla(0,100%,50%,0.05) "> < span style ="color:#710 "> '</ span > < span style ="color:#D20 "> Column Name</ span > < span style ="color:#710 "> '</ span > </ span > , < span style ="color:#06B;font-weight:bold "> sortFunction</ span > : < span style ="color:#080;font-weight:bold "> function</ span > (a, b){} }
236
+ < div class ="highlighter-coderay "> < div class ="CodeRay ">
237
+ < div class ="code "> < pre > < span class ="line-numbers "> < a href ="#n1 " name ="n1 "> 1</ a > </ span > {< span style ="color:#606 "> column</ span > : < span style ="background-color:hsla(0,100%,50%,0.05) "> < span style ="color:#710 "> '</ span > < span style ="color:#D20 "> Column Name</ span > < span style ="color:#710 "> '</ span > </ span > , < span style ="color:#06B;font-weight:bold "> sortFunction</ span > : < span style ="color:#080;font-weight:bold "> function</ span > (a, b){} }
236
238
</ pre > </ div >
237
239
</ div >
238
240
</ div >
@@ -241,16 +243,15 @@ <h3 id="sorting">Sorting</h3>
241
243
with a column and a < code > direction</ code > paramenter of either < code > asc</ code > or < code > desc</ code > .
242
244
If no direction is specified, the default sort will be ascending. Example:</ p >
243
245
244
- < div > < div class ="CodeRay ">
245
- < div class ="code "> < pre > < span class ="line-numbers "> < a href ="#n1 " name ="n1 "> 1</ a > </ span >
246
- < span class ="line-numbers "> < a href ="#n2 " name ="n2 "> 2</ a > </ span > {< span style ="color:#606 "> column</ span > : < span style ="background-color:hsla(0,100%,50%,0.05) "> < span style ="color:#710 "> '</ span > < span style ="color:#D20 "> Column Name</ span > < span style ="color:#710 "> '</ span > </ span > , < span style ="color:#606 "> direction</ span > : < span style ="background-color:hsla(0,100%,50%,0.05) "> < span style ="color:#710 "> '</ span > < span style ="color:#D20 "> asc</ span > < span style ="color:#710 "> '</ span > </ span > }
246
+ < div class ="highlighter-coderay "> < div class ="CodeRay ">
247
+ < div class ="code "> < pre > < span class ="line-numbers "> < a href ="#n1 " name ="n1 "> 1</ a > </ span > {< span style ="color:#606 "> column</ span > : < span style ="background-color:hsla(0,100%,50%,0.05) "> < span style ="color:#710 "> '</ span > < span style ="color:#D20 "> Column Name</ span > < span style ="color:#710 "> '</ span > </ span > , < span style ="color:#606 "> direction</ span > : < span style ="background-color:hsla(0,100%,50%,0.05) "> < span style ="color:#710 "> '</ span > < span style ="color:#D20 "> asc</ span > < span style ="color:#710 "> '</ span > </ span > }
247
248
</ pre > </ div >
248
249
</ div >
249
250
</ div >
250
251
251
252
< p > Combined example:</ p >
252
253
253
- < div > < div class ="CodeRay ">
254
+ < div class =" highlighter-coderay " > < div class ="CodeRay ">
254
255
< div class ="code "> < pre > < span class ="line-numbers "> < a href ="#n1 " name ="n1 "> 1</ a > </ span > <Table className=< span style ="background-color:hsla(0,100%,50%,0.05) "> < span style ="color:#710 "> "</ span > < span style ="color:#D20 "> table</ span > < span style ="color:#710 "> "</ span > </ span > id=< span style ="background-color:hsla(0,100%,50%,0.05) "> < span style ="color:#710 "> "</ span > < span style ="color:#D20 "> table</ span > < span style ="color:#710 "> "</ span > </ span > data={[
255
256
< span class ="line-numbers "> < a href ="#n2 " name ="n2 "> 2</ a > </ span > { < span style ="color:#606 "> Name</ span > : < span style ="background-color:hsla(0,100%,50%,0.05) "> < span style ="color:#710 "> '</ span > < span style ="color:#D20 "> Lee Salminen</ span > < span style ="color:#710 "> '</ span > </ span > , < span style ="color:#606 "> Age</ span > : < span style ="background-color:hsla(0,100%,50%,0.05) "> < span style ="color:#710 "> '</ span > < span style ="color:#D20 "> 23</ span > < span style ="color:#710 "> '</ span > </ span > , < span style ="color:#606 "> Position</ span > : < span style ="background-color:hsla(0,100%,50%,0.05) "> < span style ="color:#710 "> '</ span > < span style ="color:#D20 "> Programmer</ span > < span style ="color:#710 "> '</ span > </ span > },
256
257
< span class ="line-numbers "> < a href ="#n3 " name ="n3 "> 3</ a > </ span > { < span style ="color:#606 "> Name</ span > : < span style ="background-color:hsla(0,100%,50%,0.05) "> < span style ="color:#710 "> '</ span > < span style ="color:#D20 "> Griffin Smith</ span > < span style ="color:#710 "> '</ span > </ span > , < span style ="color:#606 "> Age</ span > : < span style ="background-color:hsla(0,100%,50%,0.05) "> < span style ="color:#710 "> '</ span > < span style ="color:#D20 "> 18</ span > < span style ="color:#710 "> '</ span > </ span > , < span style ="color:#606 "> Position</ span > : < span style ="background-color:hsla(0,100%,50%,0.05) "> < span style ="color:#710 "> '</ span > < span style ="color:#D20 "> Engineer</ span > < span style ="color:#710 "> '</ span > </ span > },
@@ -274,15 +275,16 @@ <h3 id="sorting">Sorting</h3>
274
275
< span class ="line-numbers "> < a href ="#n21 " name ="n21 "> 21</ a > </ span > < span style ="background-color:hsla(300,100%,50%,0.06) "> < span style ="color:#808 "> </ span > </ span > </ pre > </ div >
275
276
</ div >
276
277
</ div >
277
- < p > ### Filtering</ p >
278
+
279
+ < h3 id ="filtering "> Filtering</ h3 >
278
280
279
281
< p > You can do simple case-insensitive filtering by specifying a filterable property on the table. This
280
282
property should contain a list of columns which the filter is performed on. If the filterable property
281
283
is provided, then an input box with class reactable-filter-input will be prepended to the thead of the table.</ p >
282
284
283
285
< p > Example:</ p >
284
286
285
- < div > < div class ="CodeRay ">
287
+ < div class =" highlighter-coderay " > < div class ="CodeRay ">
286
288
< div class ="code "> < pre > < span class ="line-numbers "> < a href ="#n1 " name ="n1 "> 1</ a > </ span > < span style ="color:#070;font-weight:bold "> <Table</ span > < span style ="color:#b48 "> className</ span > =< span style ="background-color:hsla(0,100%,50%,0.05) "> < span style ="color:#710 "> "</ span > < span style ="color:#D20 "> table</ span > < span style ="color:#710 "> "</ span > </ span > < span style ="color:#b48 "> id</ span > =< span style ="background-color:hsla(0,100%,50%,0.05) "> < span style ="color:#710 "> "</ span > < span style ="color:#D20 "> table</ span > < span style ="color:#710 "> "</ span > </ span > < span style ="color:#b48 "> data</ span > =< span style ="color:#F00;background-color:#FAA "> {</ span > < span style ="color:#F00;background-color:#FAA "> [</ span >
287
289
< span class ="line-numbers "> < a href ="#n2 " name ="n2 "> 2</ a > </ span > < span style ="color:#F00;background-color:#FAA "> {</ span > < span style ="background-color:hsla(0,100%,50%,0.05) "> < span style ="color:#710 "> '</ span > < span style ="color:#D20 "> State</ span > < span style ="color:#710 "> '</ span > </ span > < span style ="color:#b48 "> :</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#b48 "> New</ span > < span style ="color:#b48 "> York</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#F00;background-color:#FAA "> ,</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#b48 "> Description</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#b48 "> :</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#b48 "> this</ span > < span style ="color:#b48 "> is</ span > < span style ="color:#b48 "> some</ span > < span style ="color:#b48 "> text</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#F00;background-color:#FAA "> ,</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#b48 "> Tag</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#b48 "> :</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#b48 "> new</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#F00;background-color:#FAA "> }</ span > < span style ="color:#F00;background-color:#FAA "> ,</ span >
288
290
< span class ="line-numbers "> < a href ="#n3 " name ="n3 "> 3</ a > </ span > < span style ="color:#F00;background-color:#FAA "> {</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#b48 "> State</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#b48 "> :</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#b48 "> New</ span > < span style ="color:#b48 "> Mexico</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#F00;background-color:#FAA "> ,</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#b48 "> Description</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#b48 "> :</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#b48 "> lorem</ span > < span style ="color:#b48 "> ipsum</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#F00;background-color:#FAA "> ,</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#b48 "> Tag</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#b48 "> :</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#b48 "> old</ span > < span style ="color:#F00;background-color:#FAA "> '</ span > < span style ="color:#F00;background-color:#FAA "> }</ span > < span style ="color:#F00;background-color:#FAA "> ,</ span >
0 commit comments