File tree 2 files changed +60
-0
lines changed
examples/js/column-format
2 files changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import React from 'react';
3
3
import HtmlColumnFormatTable from './html-column-format-table' ;
4
4
import ReactColumnFormatTable from './react-column-format-table' ;
5
5
import ExtraDataColumnFormatTable from './extra-data-column-format-table' ;
6
+ import GetRowIndexTable from './get-row-index-table' ;
6
7
7
8
class Demo extends React . Component {
8
9
render ( ) {
@@ -35,6 +36,16 @@ class Demo extends React.Component {
35
36
</ div >
36
37
</ div >
37
38
</ div >
39
+ < div className = 'col-md-offset-1 col-md-8' >
40
+ < div className = 'panel panel-default' >
41
+ < div className = 'panel-heading' > Get Row Index Example</ div >
42
+ < h5 > < b > Use the < code > fourth</ code > argument to get the row index</ b > . Check the browser console</ h5 >
43
+ < div className = 'panel-body' >
44
+ < h5 > Source in /examples/js/column-format/get-row-index-table.js</ h5 >
45
+ < GetRowIndexTable />
46
+ </ div >
47
+ </ div >
48
+ </ div >
38
49
</ div >
39
50
) ;
40
51
}
Original file line number Diff line number Diff line change
1
+ /* eslint max-len: 0 */
2
+ /* eslint no-unused-vars: 0*/
3
+ import React from 'react' ;
4
+ import { BootstrapTable , TableHeaderColumn } from 'react-bootstrap-table' ;
5
+
6
+
7
+ const jobs = [ ] ;
8
+
9
+ function addProducts ( quantity ) {
10
+ const startId = jobs . length ;
11
+ for ( let i = 0 ; i < quantity ; i ++ ) {
12
+ const id = startId + i ;
13
+ jobs . push ( {
14
+ id : id ,
15
+ name : 'Application_Name_ ' + id ,
16
+ active : i % 2 === 0 ? true : false
17
+ } ) ;
18
+ }
19
+ }
20
+
21
+ addProducts ( 5 ) ;
22
+
23
+
24
+ class ActiveFormatter extends React . Component {
25
+ render ( ) {
26
+ return (
27
+ < input type = 'checkbox' checked = { this . props . active } />
28
+ ) ;
29
+ }
30
+ }
31
+
32
+ function activeFormatter ( cell , row , enumObject , index ) {
33
+ console . log ( `The row index: ${ index } ` ) ;
34
+ return (
35
+ < ActiveFormatter active = { cell } />
36
+ ) ;
37
+ }
38
+
39
+ export default class GetRowIndexTable extends React . Component {
40
+ render ( ) {
41
+ return (
42
+ < BootstrapTable data = { jobs } >
43
+ < TableHeaderColumn dataField = 'id' isKey = { true } > Job ID</ TableHeaderColumn >
44
+ < TableHeaderColumn dataField = 'name' > Job Name</ TableHeaderColumn >
45
+ < TableHeaderColumn dataField = 'active' dataFormat = { activeFormatter } > Active</ TableHeaderColumn >
46
+ </ BootstrapTable >
47
+ ) ;
48
+ }
49
+ }
You can’t perform that action at this time.
0 commit comments