-
Notifications
You must be signed in to change notification settings - Fork 776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dataField can't access subobject #50
Comments
Hi @kopax, the nested object does not supported on newest version in this component, sorry for that. But I can add it in the future, but this is not in my plan, so I need more plan or thinking on this feature. :) |
I have made a little modification in TableBody.js /blob/master/lib/TableBody.js line 101 replaced by :
What do you think ? Edit: I have just tried with filter field, doesn't work (input placeholder is "Person.firstname") |
Hi @kopax , it's a way to implement this feature and I think it will be OK. but there are a lots of feature in this component, include cell edit, filter ..etc. so I need to consider these part for design this feature, so it will take some time. Anyway, if you just want to "display" the nested data on component, I think your solution is ok :) |
Hi @AllenFang , I am really trying hard to implement subobject management but the problem is that some comments are missing in your code. My idea would be to add a |
Hi @kopax , did you folk my project? I cant find your repository. I thinks I can spend a little time to watch out your folk and help you debug :) |
I didn't for some (stupid) reasons : I have two table Person and User The current add/edit feature add new User instance to dataSet with wrong nested Object (created key is I think I can't use this feature so I will need to do a bunch of modification just for my needs |
Hi @kopax, you mean you want the add/edit feature work with nested object? If yes, I thinks it's a very very hard work. And you really cant solve the problem on your side, I can help you, but you need give me your folk first |
This feature is definitely welcomed. the fact that it does not support nested objects make it feel rather rigid in design. I hope to see this implemented soon =) |
@AllenFang sorry for not replying. I really liked your table unfortunately I wasn't able to implement anything in your code. |
that's ok, I know this feature is very important, but I'm busy and there are lot of things to do, so I prefer to fix bug first. If I've free time, I'll come back and support this features. Anyway, PR is welcome :) |
+1 |
+1 |
1 similar comment
+1 |
+1 |
2 similar comments
+1 |
+1 |
using dataFormat to rewrite this cell . |
I did have a look at the code and this seems complicated to implement the way it is made. I doubt this feature will be added in the futur. |
@kopax, yes, it's little hard to implement.. I only have a way, is create a preparer and flat the nested object according user's defined and take this flatted object into table. I prefer to tackle Sorry, make this issue pending... |
Ok, all I can say is thanks for sharing the code. Wait & see |
Really need this feature too.. |
👍 Is there any fork of this project with this feature? |
+1 |
You can use const column_meta = [
{columnName: 'user_detail.phone_number', displayName: 'User Phone'},
];
function extraFormatter(cell, row, extra) {
return eval(`row.${extra}`);
}
let columns = column_meta.map(i => {
return <TableHeaderColumn dataField={i.columnName} dataFormat={extraFormatter} formatExtraData={i.columnName}>
{i.displayName}</TableHeaderColumn>
}); then add colunms to |
@gengjiawen, I will. Sorry for making this feature delay |
And this is quite common case if you are using graphql.However, you can easily hack it even without eval, google |
+1 |
I'm using lodash's 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>
)) |
I was just about to add to this... Why can't we simply make a PR that uses both the lodash When retrieving and setting values? |
+1 still no fix for this? |
@ferrwanz the key is missings in your code: import _ from "lodash"; const renderCustom = (cell, row, extra) => { {value} ;}; const columns = [ const tableColumn = _.map(columns, column => (
|
hey @nivek91, any thoughts on sorting this nested field? |
which field @aaronhayes ? |
I solved the issue without modification of the project 👍 and the function : |
Working example with the required field is the key. Thanks to ferrwanz and nivek91. import _ from 'lodash';
const renderCustom = (cell, row, extra) => {
const value = _.get(row, extra.path);
return <div>{value}</div>;
};
const columns = [
{ path: "id", title: "ID", isKey:true },
{ path: "animal.cat", title: "Cat" },
];
const tableColumn = _.map(columns, column => (
<TableHeaderColumn
dataField={column.path}
dataFormat={renderCustom}
formatExtraData={column}
isKey={column.isKey}
key={column.path}
>{column.title}</TableHeaderColumn>
)); Then you need to add to the method render, next code: render() {
return(
<BootstrapTable data={ transactionData }>
{tableColumn}
</BootstrapTable>
);
} |
@logolevel does all the features works ? |
kopax, yes. |
@logolevel thanks so much for this example. I am trying to aggregate data within one column like animal.firstname + animal.lastname into a path (yes I named my cat with a full name ;)). Does any one have a solution for that? |
building on @PraxentSupport's response. I'm using:
Note: need to ad ` around return values. |
@StohlmanMatteo |
Building off the above: (This is using lodash but can work out how to use if dont want to use lodash/underscore) First create a method in your react component like this replacing 'datapropertywithnested.nestedpropertyname' this your specifics:
Then in your table: |
However the above solution doesn't support filtering As such I found the easiest solution is to modily your data before it enters the table to flatten it, such as through:
Table as regular:
|
sorry guys, as I mention on README, I already decide to create Feel free to let me know your idea and any idea/issues is welcome on Sorry for inconvenience. |
Any updates? |
To people finding this thread: Using lodash works well with displaying data but the data presented will not be searchable or sortable.
|
@Ogglas any idea about sorting the field? or any approach to dataSort and also dataFormat with formatExtraData? Thanks. |
To go furthher into nested fields, i'm passing string and then returning the key/value pair.
|
Or the simplest way:
you need also |
I have an object which is like that
I can't access the subojbect using
Is there any workaround not specified in the doc ?
The text was updated successfully, but these errors were encountered: