imballinst / react-bs-datatable

Bootstrap datatable without jQuery. Features include: filter, sort, pagination, checkbox, and control customization.
https://imballinst.github.io/react-bs-datatable
MIT License
59 stars 20 forks source link

feat: add support for nested objects via `prop` object #204

Closed JWThewes closed 8 months ago

JWThewes commented 8 months ago

Add support for nested objects. This allows to access properties of nested objects via "." notation.

JWThewes commented 8 months ago

Quick update: I fixed the stuff you mentioned (Formatting and copy&past error). I also added a first version of NestedKey support. Therefore I changed the generic of TableColumnType to hope that is ok? One last bit is missing. In my case rocket is optional on the data. It all works but inside the IDE you get an error for optional types. As of now I have no idea how to support optional types with NestedKeyOf.

If you have any idea happy to see what you can do here...

imballinst commented 8 months ago

I fixed the stuff you mentioned (Formatting and copy&past error). I also added a first version of NestedKey support. Therefore I changed the generic of TableColumnType to hope that is ok?

Thanks! Appreciate it. And yeah, it seems fine to me.

One last bit is missing. In my case rocket is optional on the data. It all works but inside the IDE you get an error for optional types. As of now I have no idea how to support optional types with NestedKeyOf.

hmmm, that's a good point. Let me check on my end and see if I can help with it.

imballinst commented 8 months ago

I have tried to fix the thing, mostly around 3 parts:

  1. Add the engine field to the story data
  2. Make DatatableWrapper generic type to also extends object
  3. and somewhat follow the original GetNestedKeys utility type

Let me know if you have concerns about these updates @JWThewes, thanks! If not, then I think I can merge this and release it sometimes tomorrow my morning.

JWThewes commented 8 months ago

Looks good. Thanks for helping out! Looking forward to that release 👌

imballinst commented 8 months ago

This PR has now been released: 🎉

Let me know if you have issues with the latest build. Thanks!

JWThewes commented 8 months ago

It's working so far. Only thing missing is sorting and filter support for nested properties. Totally forgot about these. Will have to take a look to make it working...

imballinst commented 8 months ago

......that's a good point. I guess we need to expand the Storybook story a little bit and add tests for the sort/filter. Should be relatively straightforward, though, we can just replace row[prop] with getProp(row, prop) where getProp is our .reduce() thingy.

JWThewes commented 7 months ago

Just opened the PR https://github.com/imballinst/react-bs-datatable/pull/206 to add sorting and filtering support. Happy to get your feedback and see it merged and released :)