Extra model attributes for a table data source from API


#1

I’m using ember-models-table which takes in a model as the data source for the table.

The model is being updated live with a websocket.

I have extra attributes I want to add for the table which are not in the model and are queried from a separate database. How can I add these to the data source? I’d like to update this at a regular interval, perhaps with run.later.

I currently have a custom component for these columns but doing this disables any table sorting/filtering and it forces me to query each cell separately.

I thought to make a copy of the model but then I would lose the websocket pushPayLoad functionality.


#2

I solved this problem. It’s possible to set properties on the model without having them defined in the model.

I load the values from the separate database in the component on the didReceiveAttrs hook. I can then sort these columns. This hook fires again if a different dynamic route is selected or a column resorted. I didn’t figure out how to regularly fetch the data again after a set interval.

The websocket data updates the model with pushPayLoad as normal.