AllenFang / AllenFang/react-bootstrap-table

OnExpand Callback when you programatically set expanding

Aberta
#1,594 3 comentários 0 reações 0 responsáveis Ver no GitHub
enhancement in progress
Linguagem predominante
JavaScript
Estrelas
2.2k
Forks
761
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

Hi,
I have implemented the custom search and filter, and have OnExpand callback set which gets when i click on the expandable row, however, it is not being called when I programmatically set the expanding attribute. Could you please let me know how to make sure it is called even when I set the expanding attribute

The example code is below
when i do this.setState({ expanding: expanding}) in custom search funtion this.handleExpand
is not being called

```
/* eslint max-len: 0 */
/* eslint no-console: 0 */
import React from 'react';
import { BootstrapTable, TableHeaderColumn } from 'react-bootstrap-table';

const products = [];

function addProducts(quantity) {
const startId = products.length;
for (let i = 0; i < quantity; i++) {
const id = startId + i;
products.push({
id: id,
name: 'Item name ' + id,
price: 2100 + i,
expand: [ {
fieldA: 'test1',
fieldB: (i + 1) * 99,
fieldC: (i + 1) * Math.random() * 100,
fieldD: '123eedd' + i
}, {
fieldA: 'test2',
fieldB: i * 99,
fieldC: i * Math.random() * 100,
fieldD: '123eedd' + i
} ]
});
}
}
addProducts(5);

class BSTable extends React.Component {
render() {
if (this.props.data) {
return (

Field A
Field B
Field C
Field D
);
} else {
return (

?

);
}
}
}

export default class ExpandRow extends React.Component {
constructor(props) {
super(props);
this.handleExpand = this.handleExpand.bind(this);
this.state = {
// Default expanding row
expanding: [ 2 ]
};
}

isExpandableRow() {
return true;
}

handleExpand(rowKey, isExpand) {
if (isExpand) {
console.log(`row: ${rowKey} is ready to expand`);
} else {
console.log(`row: ${rowKey} is ready to collapse`);
}
}

expandComponent(row) {
return (

);
}

render() {
const options = {
expandRowBgColor: 'rgb(66, 134, 244)',
expanding: this.state.expanding,
onExpand: this.handleExpand
};
return (

Product ID
Product Name
Product Price

);
}
}
```

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.