question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dataField can't access subobject

See original GitHub issue

I have an object which is like that

{
  "person_id": 1,
    "username": "UserTest",
    "created_at": "2015-09-10T21:13:56.000Z",
    "updated_at": "2015-09-10T21:13:56.000Z",
    "deleted_at": null,
    "Person": {
          "id": 1,
          "firstname": "UserTest",
          "lastname": "Obama",
          "note": "DevOps",
          "email": "iam@obama.com",
          "created_at": "2015-09-10T21:13:56.000Z",
          "updated_at": "2015-09-10T21:13:56.000Z",
          "deleted_at": null
    }
}

I can’t access the subojbect using

<TableHeaderColumn dataField="Person.firstname">Firstname</TableHeaderColumn>

Is there any workaround not specified in the doc ?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:25
  • Comments:51 (9 by maintainers)

github_iconTop GitHub Comments

10reactions
AllenFangcommented, Aug 20, 2017

sorry guys, as I mention on README, I already decide to create react-bootstrap-table2, I trust it will be better than react-bootstrap-table. A good news is I’ll support the nested data in react-bootstrap-table2 start from v0.0.1, bad news is I will not support the nested data in react-bootstrap-table.

Feel free to let me know your idea and any idea/issues is welcome on react-bootstrap-table2

Sorry for inconvenience.

9reactions
ferrwancommented, Feb 14, 2017

I’m using lodash’s _.get lib to achieve this.

import _ from 'lodash'

const renderCustom = (cell, row, extra) => {
    const value = _.get(row, extra.path)
    return <div>{value}</div>
}

const columns = [
    {path: 'Person.firstname', title: 'Firstname'},
    {path: 'Person.lastname', title: 'Lastname'},
    {path: 'this.is.a.long.path.of.an.object', title: 'Long Path'},
]

const tableColumn = _.map(columns, (column) => (
    <TableHeaderColumn
        dataField={column.path}
        dataFormat={renderCustom}
        formatExtraData={column}
    >{column.title}</TableHeaderColumn>
))
Read more comments on GitHub >

github_iconTop Results From Across the Web

react-bootstrap-table can't access sub object - Stack Overflow
When I try to access property {manufacturer.name} in my table data field, it doesn't show anything on the screen. <BootstrapTable data={features} ...
Read more >
List sub object sorting and grouping issues - Telerik Forums
I am creating a grid programmatically within a page. The datasource is an object list in which the objects contain lists as sub-objects....
Read more >
Access property in child object from the GridView control ...
I am running into a small issue... In my gridview I would like to display the InventoryItem.Rack.RackName property but it says that it...
Read more >
SQL and Array Data - InfoWorks ICM - Innovyze
The most obvious one is the Bends data field, which stores the intermediate (x,y) pairs that ... Again you cannot access individual values...
Read more >
Optional data field's mapping - jQWidgets
We cannot reproduce a problem with this version of jQWidgets. ... simple test will stop trying to get property if any sub-object is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found