Griddle icon indicating copy to clipboard operation
Griddle copied to clipboard

Columns with dots in their property names will be empty

Open ibrahima opened this issue 6 years ago • 4 comments

Griddle version

v1.9.0

Expected Behavior

Columns with dots in their ids should show their contents.

Actual Behavior

Columns with dots in their names have no data.

This is the same issue as before, but the code is all different.

https://github.com/GriddleGriddle/Griddle/issues/228

I tracked it down to this line:

https://github.com/griddlegriddle/griddle/blob/master/src/selectors/dataSelectors.js#L265..L265

Since you're splitting the property name by dots, this is going to try to access properties that don't exist.

Steps to reproduce

  1. Set up a Griddle table with a data column like "foo.bar"
  2. Look at the table.

Pull request with failing test or storybook story with issue

TODO (trying to figure out how best to do this right now, or whether I should just work around it in my app for now)

ibrahima avatar Oct 11 '17 20:10 ibrahima

Looking at the git blame, it seems like it's intended that you should be able to use dots to access nested values? If so, how should one use columns that have dots in the names? I think for now I'll just work around this in my app by filtering the data before passing it to Griddle.

ibrahima avatar Oct 11 '17 20:10 ibrahima

Nested data support was introduced in https://github.com/GriddleGriddle/Griddle/pull/572.

I wonder if it would make sense to support nestedData={false} or similar? Or we could update cellValueSelector to (essentially) get(columnId) || getIn(columnId.split('.')).

As you note, the work-around would be to map the data to objects with simple column names.

dahlbyk avatar Oct 11 '17 20:10 dahlbyk

Ah okay, so it's totally intentional new behavior. Thanks!

A prop would be nice, or changing the behavior to get(columnId) || getIn(columnId.split('.')) would probably be even better because it seems like it's not necessarily something that you expect, especially if your application is rendering user-submitted data.

ibrahima avatar Oct 11 '17 20:10 ibrahima

So this issue is still open and no fix is it?

vivek-kandhvar avatar Feb 12 '20 08:02 vivek-kandhvar