Skip to content

Instantly share code, notes, and snippets.

@taras
Last active August 29, 2015 14:15
Show Gist options
  • Save taras/c7c9d938f1518623e1e8 to your computer and use it in GitHub Desktop.
Save taras/c7c9d938f1518623e1e8 to your computer and use it in GitHub Desktop.
Ember Table 2.0
{{#if template}}
{{yield columns rows}}
{{else}}
{{#ember-table data=data columns=columnsData as |columns rows|}}
{{#table-header columns=columns as |name|}}
{{name}}
{{/table-header}}
{{#table-body rows=rows as |value column|}}
{{value}}
{{/table-body}}
{{#table-footer as |summary column|}}
{{summary}}
{{/table-footer}}
{{/ember-table}}
{{/if}}
# Table Template
```
{{#if template}}
{{yield columns rows}}
{{else}}
{{#ember-table data=data columns=columnsData as |columns rows|}}
{{#table-header columns=columns as |name|}}
{{name}}
{{/table-header}}
{{#table-body rows=rows as |value column|}}
{{value}}
{{/table-body}}
{{#table-footer as |summary column|}}
{{summary}}
{{/table-footer}}
{{/ember-table}}
{{/if}}
```
# Barebone Table
```
{{#ember-table data=data columns=columnsData as |columns rows|}}
{{#table-header columns=columns as |name|}}
{{name}}
{{/table-header}}
{{#table-body rows=rows as |value column|}}
{{value}}
{{/table-body}}
{{#table-footer as |summary column|}}
{{summary}}
{{/table-footer}}
{{/ember-table}}
```
# Sorting
```
{{#ember-table data=data columns=columnsData as |columns rows|}}
{{#table-header columns=columns as |name column|}}
{{#action 'sortData' column}}{{name}}{{/action}}
{{/table-header}}
...
{{/ember-table}}
```
# Customizing Table Cells
```
{{#ember-table data=data columns=columnsData as |columns rows|}}
{{#table-body rows=rows as |value column|}}
{{#if (eq column.type 'date')}}
{{format-date value}}
{{else if (eq column.type 'component')}}
{{component column.componentName value=value}}
{{else}}
{{value}}
{{#if}}
{{/table-body}}
...
{{/ember-table}}
```
{{#ember-table data=data columns=columnsData as |columns rows|}}
{{#table-header columns=columns as |name|}}
{{name}}
{{/table-header}}
{{#table-body rows=rows as |value column|}}
{{value}}
{{/table-body}}
{{#table-footer as |summary column|}}
{{summary}}
{{/table-footer}}
{{/ember-table}}
{{#ember-table data=data columns=columnsData as |columns rows|}}
{{#table-header columns=columns as |name column|}}
{{#action 'sortData' column}}{{name}}{{/action}}
{{/table-header}}
...
{{/ember-table}}
{{#each row in rows}}
{{#each column in columns}}
{{#if template}}
{{yield column row}}
{{else}}
{{component column.componentName row=row column=column}}
{{/if}}
{{/each}}
{{/each}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment