Created
February 14, 2013 18:31
-
-
Save jonnii/4955052 to your computer and use it in GitHub Desktop.
simple dynamic table view in ember.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{view App.SimpleTableView rowsBinding="results" columnsBinding="columns"}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.SimpleTableView = Ember.View.extend | |
tagName: 'tbody' | |
template: Ember.Handlebars.compile '{{view.formattedContent}}' | |
formattedContent: (-> | |
rows = @get 'rows' | |
columns = @get 'columns' | |
return unless rows | |
return unless columns | |
table = '' | |
rows.forEach (row) -> | |
table += '<tr>' | |
columns.forEach (c) -> | |
value = row[c.name.underscore()] | |
value = '' unless value | |
table += "<td>#{value}</td>" | |
table += '</tr>' | |
new Handlebars.SafeString table | |
).property('items') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment