Skip to content

Instantly share code, notes, and snippets.

@kristianfreeman
Created December 10, 2014 23:34
Show Gist options
  • Save kristianfreeman/2353cd68c0a0ff17733c to your computer and use it in GitHub Desktop.
Save kristianfreeman/2353cd68c0a0ff17733c to your computer and use it in GitHub Desktop.
implementing dynamic rowHeight per list-view item
// ...
heightForIndex: function(idx){
var entry = this.get('content').objectAt(idx);
if (entry.get('rowHeight')) {
return entry.get('rowHeight');
} else {
return this.rowHeight;
}
},
updateRows: Ember.observer('[email protected]', function() {
// lodash dep here
_.each(this.get('childViews'), function(view) {
if (!view.get('isDestroying'))
view.set('rowHeight', view.get('content.rowHeight'));
});
this._rowHeightDidChange();
}),
// ...
@mysterlune
Copy link

@imkmf, this is really straightforward. so it looks like you have a rowHeight property on your model object itself. does your data come from your remote service? or do you know up front what your record's default value is for rowHeight?

also, i dig the lodash usage ;) seems like you can just use ember's own this.get('chidlViews').forEach(...) on that one, though, right? are you getting better performance from lodash?

@SebastianSzturo
Copy link

Thanks for sharing ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment