(props)
| 67 | } |
| 68 | |
| 69 | initTable(props) { |
| 70 | // If columns changed, clean removed columns that had filters |
| 71 | if (props.children !== this.props.children && this.filter) { |
| 72 | const nextDataFields = React.Children.map(props.children, column => column.props.dataField); |
| 73 | React.Children.forEach(this.props.children, column => { |
| 74 | const { dataField, filter } = column.props; |
| 75 | if (filter && !nextDataFields.includes(dataField)) { |
| 76 | // Clear filter |
| 77 | this.filter.handleFilter(dataField, '', filter.type, filter); |
| 78 | } |
| 79 | }); |
| 80 | } |
| 81 | |
| 82 | let { keyField } = props; |
| 83 | |
| 84 | const isKeyFieldDefined = typeof keyField === 'string' && keyField.length; |
| 85 | React.Children.forEach(props.children, column => { |
| 86 | if (column === null || column === undefined) { |
| 87 | // Skip null and undefined value |
| 88 | return; |
| 89 | } |
| 90 | if (column.props.isKey) { |
| 91 | if (keyField) { |
| 92 | throw new Error('Error. Multiple key column detected in TableHeaderColumn.'); |
| 93 | } |
| 94 | keyField = column.props.dataField; |
| 95 | } |
| 96 | if (column.props.filter) { |
| 97 | // a column contains a filter |
| 98 | if (!this.filter) { |
| 99 | // first time create the filter on the BootstrapTable |
| 100 | this.filter = new Filter(); |
| 101 | } |
| 102 | // pass the filter to column with filter |
| 103 | column.props.filter.emitter = this.filter; |
| 104 | } |
| 105 | }); |
| 106 | |
| 107 | // if a column filter was created, add 'onFilterChange' listener |
| 108 | if (this.filter) { |
| 109 | this.filter.removeAllListeners('onFilterChange'); |
| 110 | this.filter.on('onFilterChange', (currentFilter) => { |
| 111 | this.handleFilterData(currentFilter); |
| 112 | }); |
| 113 | } |
| 114 | |
| 115 | this.colInfos = this.getColumnsDescription(props).reduce(( prev, curr ) => { |
| 116 | prev[curr.name] = curr; |
| 117 | return prev; |
| 118 | }, {}); |
| 119 | |
| 120 | if (!isKeyFieldDefined && !keyField) { |
| 121 | throw new Error(`Error. No any key column defined in TableHeaderColumn. |
| 122 | Use 'isKey={true}' to specify a unique column after version 0.5.4.`); |
| 123 | } |
| 124 | |
| 125 | this.store.setProps({ |
| 126 | isPagination: props.pagination, |
nothing calls this directly
no test coverage detected
searching dependent graphs…