Skip to content

Commit d4bcb37

Browse files
committed
add onRowClick demo
1 parent b442d95 commit d4bcb37

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

examples/js/selection/demo.js

+10
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import DefaultSelectTable from './default-select-table';
66
import SelectBgColorTable from './select-bgcolor-table';
77
import SelectHookTable from './select-hook-table';
88
import HideSelectionColumnTable from './hide-selection-col-table';
9+
import RowClickTable from './row-click-table';
910

1011
class Demo extends React.Component {
1112
render() {
@@ -74,6 +75,15 @@ class Demo extends React.Component {
7475
</div>
7576
</div>
7677
</div>
78+
<div className="col-md-offset-1 col-md-8">
79+
<div className="panel panel-default">
80+
<div className="panel-heading">Row Click Example</div>
81+
<div className="panel-body">
82+
<h5>Source in /examples/js/selection/row-click-table.js</h5>
83+
<RowClickTable />
84+
</div>
85+
</div>
86+
</div>
7787
</div>
7888
);
7989
}
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
'use strict';
2+
import React from 'react';
3+
import {BootstrapTable, TableHeaderColumn} from 'react-bootstrap-table';
4+
5+
6+
var products = [];
7+
8+
function addProducts(quantity) {
9+
var startId = products.length;
10+
for (var i = 0; i < quantity; i++) {
11+
var id = startId + i;
12+
products.push({
13+
id: id,
14+
name: "Item name " + id,
15+
price: 2100 + i
16+
});
17+
}
18+
}
19+
20+
addProducts(5);
21+
22+
var options = {
23+
onRowClick: function(row){
24+
alert('You click row id: '+row.id);
25+
}
26+
};
27+
28+
export default class SingleSelectTable extends React.Component{
29+
render(){
30+
return (
31+
<BootstrapTable data={products} options={options}>
32+
<TableHeaderColumn dataField="id" isKey={true}>Product ID</TableHeaderColumn>
33+
<TableHeaderColumn dataField="name">Product Name</TableHeaderColumn>
34+
<TableHeaderColumn dataField="price">Product Price</TableHeaderColumn>
35+
</BootstrapTable>
36+
);
37+
}
38+
};

0 commit comments

Comments
 (0)