-
-
Save kzahel/5b86054e42a9ecd898fc to your computer and use it in GitHub Desktop.
This file contains 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
<dom-module id="my-table"> | |
<template> | |
<!--iron-list items="[[items]]" as="item"> | |
<template> | |
<div> | |
Name: [[item.name.first]] | |
</div> | |
</template> | |
</iron-list--> <!-- this will re-render correctly when items are added --> | |
<iron-data-table items="[[items]]"> | |
<data-table-column name="First Name" sort-by="name.first"> | |
<template>[[ item.name.first ]]</template> | |
</data-table-column> | |
<data-table-column name="Last Name" sort-by="name.last"> | |
<template>[[ item.name.last ]]</template> | |
</data-table-column> | |
<data-table-column name="Title" sort-by="name.title"> | |
<template>[[ item.name.title ]]</template> | |
</data-table-column> | |
</iron-data-table> | |
</template> | |
</dom-module> | |
<my-table></my-table> |
This file contains 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
Polymer({ | |
is: 'my-table', | |
observers: [ | |
'usersAddedOrRemoved(items.splices)' | |
], | |
properties: { | |
items: {type:Array, | |
value:[], | |
notify:true} | |
}, | |
usersAddedOrRemoved: function(splices) { | |
console.log('users added or removed',splices) | |
}, | |
addUser: function(user) { | |
this.push('items', user) | |
}, | |
ready: function() { | |
console.log('my-table ready') | |
this.addUser({name:{first:"bob",last:"smith",title:'mr'}}) | |
this.addUser({name:{first:"dan",last:"smith",title:'mr'}}) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment