react-bootstrap-table2 icon indicating copy to clipboard operation
react-bootstrap-table2 copied to clipboard

dataField does not support dot notation

Open anikakalbrun opened this issue 8 years ago • 4 comments

const columns = [
    {
        text: 'Claimed By',
        dataField: 'claimBy.name',
        filter
    }
]

The BootstrapTable does not show records in the Claimed By column when the dataFields value is a string with dot notation. This does not allow me to build a proper url and use the onTableChange method to make an HTTP request to get filtered table data from the server.

When I change the data passed to the table and the columns value to:

const columns = [
    {
        text: 'Claimed By',
        dataField: 'claimBy',
        filter
    }
]

then the BootstrapTable shows proper records in the Claimed By column.

I am using: "react-bootstrap-table-next": "^0.1.4", "react-bootstrap-table2-filter": "^0.1.3", "react-bootstrap-table2-paginator": "^0.1.1",

anikakalbrun avatar Mar 14 '18 12:03 anikakalbrun

@anikakalbrun sorry for lately reply, can I check your raw data? I think nested field is support from the starting of react-bootstrap-table2, thanks

AllenFang avatar Mar 18 '18 05:03 AllenFang

Hi Allen,

Thanks a lot for getting back to me.

This code is not working for me:

` const columns = [ { text: "Claimed By", dataField: "claimBy.name" }, { text: "Expenses", dataField: "totalExpenses" } ];

class ExpensesTable extends React.Component {

render() {
    const {data} = this.props;
    return (
        <BootstrapTable keyField="id"
                        data={data}
                        columns={columns}
                        hover
        />

    )
}

}

function mapStateToProps() { return { data: [ { "id": "4ca067bd-39f5-4fee-b23e-eaea2f5e033e", "claimBy.name": "Diane Diaz", "totalExpenses": 1124.39 } ] }; }

export default connect(mapStateToProps)(ExpensesTable); ` The first column stays empty.

anikakalbrun avatar Mar 21 '18 17:03 anikakalbrun

@anikakalbrun sorry, your data should be following:

{
  id: "4ca067bd-39f5-4fee-b23e-eaea2f5e033e",
  claimBy: { .name: 'Diane Diaz' },
  totalExpenses: 1124.39
}

docs

AllenFang avatar Mar 25 '18 08:03 AllenFang

Hey @AllenFang, Is there a way to disable to disable the processing of dot notation as a nested object? I would like to retain the column as

"claimBy.name": "Diane Diaz"

Vasanth-Indix avatar Jun 21 '19 05:06 Vasanth-Indix