[英]how can I have CollectionView of CollectionView in marionette.js?
[英]How can I add a <thead> section to a marionette collectionview with tagName: 'table'?
我有一个看起来像这样的集合视图:
var PersonView = Marionette.ItemView.extend({
tagName: 'tr',
template: function (model) {
return _.template("<td><%= data.firstName %></td><td><%= data.lastName %></td>", {
firstName: model.firstName,
lastName: model.lastName
}, { variable: 'data' });
}
}),
PersonCollectionView = Marionette.CollectionView.extend({
tagName: 'table',
itemView: PersonView
});
它工作正常,但我想不出在表中添加<thead>
节的最佳方法。 我想到了将tagName: 'table'
更改为tagName: 'tbody'
并在显示集合视图的布局中添加thead
部分,但这看起来不是很干净的方法。 确实,如果要在其他地方使用收藏视图,则必须以另一种布局重现thead
部分。建议的实现方式是什么?
PS请参阅https://github.com/shawninder/table-collection-views以获取工作示例。 您会注意到该表没有<thead>
部分,这是我要解决的问题。
您可能需要改用CompositeView 。 使用CompositeView
您可以提供一个模板来添加thead
并使用ItemViewContainer
呈现您的收藏集。 阅读文档 ,我相信您会找到解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.