2

I would like to add a custom row at the bottom of an ember-table so that it will allow the user to insert new rows to the table. Which approach should I take? The idea is similar to the one asked here but using a fixed row and ember-table.

Community
  • 1
  • 1
Henry Vonfire
  • 1,281
  • 10
  • 18
  • There are too many ways to approach this problem. The answers would just turn into a straw-poll for which one people liked. The best thing is to do some research on the topic yourself, find two or three, _analyze_ them, determine if they work for you or not, and _try them out_. Come to use when you have a specific question about something you have attempted to do. – gunr2171 May 19 '15 at 14:06
  • Thanks for your comment @gunr2171 but I'm talking about something very specific, which is the add-on provided by Addepar called ember-table. – Henry Vonfire May 19 '15 at 14:35

1 Answers1

0

I'd suggest extending Ember Table to override footerContent:

import Ember from 'ember';
import TableComponent from 'ember-table/components/ember-table';
MyTable = TableComponent.extend({
  footerContent: ...
});

You'd then override Ember.Table.Row with a custom row, and put that into footerContent. You could define an extra action on that row which grabs the row's data and adds it to content backing the main table. (You'd need to pass a reference to content into your custom row).

You can do the same thing by overriding bodyContent, but I think using a footer is perfect for this purpose, and I increasingly think overriding bodyContent is a bad idea.

azirbel
  • 119
  • 5
  • 1
    I'm not pretty sure how to override `Ember.table.Row`, is it like `financial-table-tree-row` in the financial table example? – Henry Vonfire May 28 '15 at 10:50
  • Ok, I managed to show in the footer some info but how can I customize the row to show input fields instead of the actual cell-template? – Henry Vonfire May 28 '15 at 11:46
  • @Henry, would you mind setting up an example in a JSBin? I'm needing to do the same thing, but I'm pretty new at Ember and not able to figure out all the code and plumbing that azirbel suggested. Thx. – JustSomeGuy Jan 07 '16 at 16:43