mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
implement selectRow.clickToExpand
This commit is contained in:
parent
6735536fd8
commit
dda8460017
@ -18,7 +18,9 @@ const columns = [{
|
||||
}];
|
||||
|
||||
const selectRow = {
|
||||
mode: 'checkbox'
|
||||
mode: 'checkbox',
|
||||
clickToSelect: true,
|
||||
clickToExpand: true
|
||||
};
|
||||
|
||||
const expandRow = {
|
||||
@ -48,7 +50,8 @@ const columns = [{
|
||||
|
||||
const selectRow = {
|
||||
mode: 'checkbox',
|
||||
clickToSelect: true
|
||||
clickToSelect: true,
|
||||
clickToExpand: true
|
||||
};
|
||||
|
||||
const expandRow = {
|
||||
@ -67,6 +70,7 @@ const expandRow = {
|
||||
data={ products }
|
||||
columns={ columns }
|
||||
selectRow={ selectRow }
|
||||
expandRow={ expandRow }
|
||||
/>
|
||||
`;
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import _ from '../utils';
|
||||
import Const from '../const';
|
||||
|
||||
const events = [
|
||||
'onClick',
|
||||
@ -38,14 +39,19 @@ export default ExtendBase =>
|
||||
}
|
||||
const key = _.get(row, keyField);
|
||||
if (expandRow && expandable) {
|
||||
expandRow.onRowExpand(key, !expanded, rowIndex, e);
|
||||
if (
|
||||
(selectRow.mode !== Const.ROW_SELECT_DISABLED && selectRow.clickToExpand) ||
|
||||
selectRow.mode === Const.ROW_SELECT_DISABLED
|
||||
) {
|
||||
expandRow.onRowExpand(key, !expanded, rowIndex, e);
|
||||
}
|
||||
}
|
||||
if (selectRow.clickToSelect && selectable) {
|
||||
selectRow.onRowSelect(key, !selected, rowIndex, e);
|
||||
}
|
||||
};
|
||||
|
||||
if (DELAY_FOR_DBCLICK && selectRow.clickToEdit) {
|
||||
if (DELAY_FOR_DBCLICK) {
|
||||
this.clickNum += 1;
|
||||
_.debounce(() => {
|
||||
if (this.clickNum === 1) {
|
||||
|
||||
@ -215,7 +215,7 @@ describe('Row Aggregator', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('if props.expandRow.renderer is defined', () => {
|
||||
describe('if props.expandRow is not defined', () => {
|
||||
describe('but expandable props is false', () => {
|
||||
const expandRow = { renderer: jest.fn(), nonExpandable: [row[keyField]] };
|
||||
beforeEach(() => {
|
||||
@ -235,7 +235,7 @@ describe('Row Aggregator', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('if props.expandRow.renderer is defined', () => {
|
||||
describe('if props.expandRow is defined', () => {
|
||||
const expandRow = { renderer: jest.fn() };
|
||||
beforeEach(() => {
|
||||
wrapper = mount(
|
||||
@ -252,7 +252,7 @@ describe('Row Aggregator', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('if props.attrs.onClick and props.expandRow.renderer both are defined', () => {
|
||||
describe('if props.attrs.onClick and props.expandRow both are defined', () => {
|
||||
const attrs = { onClick: jest.fn() };
|
||||
const expandRow = { renderer: jest.fn() };
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user