-
Notifications
You must be signed in to change notification settings - Fork 933
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
Allow passing data as an array of objects #147
Comments
I'll leave this open for community feedback |
For feedback, With my spring rest controller, I have developped utils to take my Rest JSON data and transform it to a raw data array mapped to column to be able to display the data. It will be very usefull to directly be able to read the JSON and avoid this specific mapping technique. So for short, yes interested in this functionnality ! ;) |
Same as @jkeruzec , i'm interested too :) |
Does someone started to work on this ? |
I'm interested too, it will be very usefull. |
+1 for this feature |
+1 |
Hi, this feature would be very usefull for our project. |
Are you considering to do this feature? |
It's easier if we have array of objects since data from server usually is formatted that way and we can opt to choose which properties need to be shown in the table. |
+1 |
You can use this helper function to transform: const convertDataToArray = (data, keys) =>
data.map(obj => Array.from(keys, k=>obj[k])) |
I've made in my fork + TS support: https://www.npmjs.com/package/material-datatable |
@Diaver are you going to submitting a pull request to address this issue in this project? |
@rooby I am not sure it is possible: In my form at least one big change - my datatable accept object array, not array of arrays |
@Diaver Why not adding one prop like |
@revskill10 because it is not just one required change |
@Diaver I mean let's just reuse the logic, and what we can do is transforming/processing props before passing down the render logic. Because we want to keep maintainance on one project only (?) |
@revskill10
|
You could even do it dynamically by checking the type on the data elements. Is it an array of strings? Then match it by index to the columns. Is it an object? Then match it by key to a |
Not sure why it isn't added yet, so I'm here to increase the feedback. Definitely interested on this! |
Hi If confirmed, we will be in the next version.
Source: https://github.com/mgolkardev/mui-datatables/tree/patch-1 |
Hi, |
I also would like to know if this feature will be in the mui-datatables cuz its' very useful, i'm having trouble handling the data I fetch from my APIs and transform them into array (Object.values(obj) doesn't work in this case, when the object has nested objects inside) |
How do I apply this patch to the npm installed mui-datatables? |
The latest release now supports data as objects. Example: https://github.com/gregnb/mui-datatables/blob/master/examples/data-as-objects/index.js |
@gregnb How can I access a nested property? For example: const data = [
{
id: 1,
parent: {
child: "wah"
}
}
] I want to access the child property like: columns={
[
{
name: 'parent.child',
label: 'Child'
}
]
} |
Can you specify in details...what is the key variable and all |
This appears to be broken in version 3.7.1. When I upgraded from v2, these columns stopped showing content. Here's a codesandbox to verify. https://codesandbox.io/s/tender-morning-gknfz |
thank you for reporting. As it changed to *v3
|
Thank you! This works great. |
Thanks dude. |
This is great thanks a lot. Spent hours on this |
Thanks
THanks this reall worked |
Just add <enableNestedDataAccess: '.',> in option object. const options = { Ref: Link |
It would be very useful to be able to pass in an array of object for data and then in the column definition you would specify the name of the property on the object.
It would be even better if you could specify nested properties with dot notation, similarly to how react-table works.
The text was updated successfully, but these errors were encountered: