Skip to content

Commit 848b584

Browse files
AllenFangpowellandy
authored andcommitted
example for #1750
1 parent 2a6195e commit 848b584

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

examples/js/keyboard-nav/demo.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import DisableClickToNavTable from './disable-click-to-nav-table';
88
import NavWithCellEditTable from './nav-with-cell-edit-table';
99
import CustomStyleNavWithCellEditTable from './custom-style-nav-with-cell-edit-table';
1010
import EnterToEditWithNavTable from './enter-to-edit-with-nav-table';
11+
import EnterToSelectRowWithNavTable from './enter-to-select-row-with-nav-table';
1112
import NavWithExpandingTable from './nav-with-expand-table';
1213
import EnterToExpandWithNavTable from './enter-to-expand-row-with-nav-table';
1314

@@ -71,6 +72,14 @@ class Demo extends React.Component {
7172
</span>
7273
<EnterToEditWithNavTable />
7374
</Panel>
75+
<Panel header={ 'Enter to select row with Keyboard Navigation Example' }>
76+
{ renderLinks('keyboard-nav/enter-to-select-row-with-nav-table') }
77+
<span>
78+
<code>keyBoardNav</code> accept a bool or object value<br/>
79+
Use <code>keyBoardNav.enterToSelect</code> to trigger row selection<br/>
80+
</span>
81+
<EnterToSelectRowWithNavTable />
82+
</Panel>
7483
<Panel header={ 'Expand with Keyboard Navigation Example' }>
7584
{ renderLinks('keyboard-nav/nav-with-expand-table.js') }
7685
<NavWithExpandingTable/>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* eslint max-len: 0 */
2+
import React from 'react';
3+
import { BootstrapTable, TableHeaderColumn } from 'react-bootstrap-table';
4+
5+
6+
const products = [];
7+
8+
function addProducts(quantity) {
9+
const startId = products.length;
10+
for (let i = 0; i < quantity; i++) {
11+
const 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+
export default class SimpleNavTable extends React.Component {
23+
render() {
24+
const selectRow = {
25+
mode: 'checkbox'
26+
};
27+
const keyBoardNav = {
28+
enterToSelect: true
29+
};
30+
return (
31+
<BootstrapTable data={ products } selectRow={ selectRow } keyBoardNav={ keyBoardNav }>
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)