reactive-table icon indicating copy to clipboard operation
reactive-table copied to clipboard

Sparse array generates partial table, only uses keys contained in ALL objects.

Open 0o-de-lally opened this issue 9 years ago • 3 comments

Love this package. I use it a lot. I have an edge case where I use a Meteor.Method to return an array (instead of using a collection). However this array is sparse. the result I get is a partial table, only the keys present in ALL objects.

[
{"name": "Abigail", "11/2014":  1, "12/2014":  2},
{"name": "OtherUsers", "1/2016":  1, "2/2016":  2}
]

The union of the keys above is 1, that is, they don't share keys besides "name". So the table renders with no columns except "name".

Is this intended behavior, or is there a setting I'm missing?

Thanks in advance!

0o-de-lally avatar Mar 03 '16 01:03 0o-de-lally

So you're not using the fields setting?

If you don't specify fields, it will take one element and use its keys (probably always the first for arrays but I'd have to check). This works when all the elements have the same keys, and if they don't it's not clear what should happen, so I thought it was a reasonable default.

I'm not sure why that would give just "name" in your example though.

aslagle avatar Mar 03 '16 04:03 aslagle

In my example above, there are no shared dates. If I force shared dates with null for gaps in the data, I do get a chart. BTW I did try to populate a dynamic list of headers/fields for "settings". Still the same issue. Any other tips?

0o-de-lally avatar Mar 03 '16 05:03 0o-de-lally

Did you use fieldIds when you tried the dynamic list? Without that the columns won't be reactive.

https://github.com/aslagle/reactive-table#dynamic-columns

aslagle avatar Mar 04 '16 02:03 aslagle