hyojin / material-ui-datatables

An another React Data tables component.
MIT License
165 stars 58 forks source link

object with included object #63

Closed MetteRussell closed 7 years ago

MetteRussell commented 7 years ago

I just found you library and it looks good. I do have a couple of questions.

Is it possible to show objects that are included in the "main" object?

I have a Subscription object, which includes both a Payment object and a list of Product objects. Is it possible to show data from both the Payment object and the first Product object in the table, together with data from the Subscription object (all on the same line)?

Is it possible to define the format of how a date should be presented?

Thanks in advance.

hyojin commented 7 years ago

@MetteRussell Thanks! The component takes only one data object at one time so I think you can merge your 2 data objects into 1 object before rendering. If there is no duplicated key, it should be easy and probably Object.assign or Spread operator will be helpful for you.

And it doesn't have sort of formatter function internally, but you can define custom render function for specific column and convert it to any other format. for example, (I prefer moment.js)

// column setting
{
  key: '...',
  render: (date) => <p>{moment(date).format("MM DD")}</p>
}
MetteRussell commented 7 years ago

@hyojin It works perfectly - when there is no duplicate keys .... (as you said).

I also got dates to be formattet correctly. If I render the date with a div (instead of p), the alignement is also perfect. Thanks.