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 = {
|
const selectRow = {
|
||||||
mode: 'checkbox'
|
mode: 'checkbox',
|
||||||
|
clickToSelect: true,
|
||||||
|
clickToExpand: true
|
||||||
};
|
};
|
||||||
|
|
||||||
const expandRow = {
|
const expandRow = {
|
||||||
@ -48,7 +50,8 @@ const columns = [{
|
|||||||
|
|
||||||
const selectRow = {
|
const selectRow = {
|
||||||
mode: 'checkbox',
|
mode: 'checkbox',
|
||||||
clickToSelect: true
|
clickToSelect: true,
|
||||||
|
clickToExpand: true
|
||||||
};
|
};
|
||||||
|
|
||||||
const expandRow = {
|
const expandRow = {
|
||||||
@ -67,6 +70,7 @@ const expandRow = {
|
|||||||
data={ products }
|
data={ products }
|
||||||
columns={ columns }
|
columns={ columns }
|
||||||
selectRow={ selectRow }
|
selectRow={ selectRow }
|
||||||
|
expandRow={ expandRow }
|
||||||
/>
|
/>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import _ from '../utils';
|
import _ from '../utils';
|
||||||
|
import Const from '../const';
|
||||||
|
|
||||||
const events = [
|
const events = [
|
||||||
'onClick',
|
'onClick',
|
||||||
@ -38,14 +39,19 @@ export default ExtendBase =>
|
|||||||
}
|
}
|
||||||
const key = _.get(row, keyField);
|
const key = _.get(row, keyField);
|
||||||
if (expandRow && expandable) {
|
if (expandRow && expandable) {
|
||||||
|
if (
|
||||||
|
(selectRow.mode !== Const.ROW_SELECT_DISABLED && selectRow.clickToExpand) ||
|
||||||
|
selectRow.mode === Const.ROW_SELECT_DISABLED
|
||||||
|
) {
|
||||||
expandRow.onRowExpand(key, !expanded, rowIndex, e);
|
expandRow.onRowExpand(key, !expanded, rowIndex, e);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (selectRow.clickToSelect && selectable) {
|
if (selectRow.clickToSelect && selectable) {
|
||||||
selectRow.onRowSelect(key, !selected, rowIndex, e);
|
selectRow.onRowSelect(key, !selected, rowIndex, e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (DELAY_FOR_DBCLICK && selectRow.clickToEdit) {
|
if (DELAY_FOR_DBCLICK) {
|
||||||
this.clickNum += 1;
|
this.clickNum += 1;
|
||||||
_.debounce(() => {
|
_.debounce(() => {
|
||||||
if (this.clickNum === 1) {
|
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', () => {
|
describe('but expandable props is false', () => {
|
||||||
const expandRow = { renderer: jest.fn(), nonExpandable: [row[keyField]] };
|
const expandRow = { renderer: jest.fn(), nonExpandable: [row[keyField]] };
|
||||||
beforeEach(() => {
|
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() };
|
const expandRow = { renderer: jest.fn() };
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
wrapper = mount(
|
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 attrs = { onClick: jest.fn() };
|
||||||
const expandRow = { renderer: jest.fn() };
|
const expandRow = { renderer: jest.fn() };
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user