繁体   English   中英

如何添加 <thead> 带有tagName:&#39;table&#39;的木偶collectionview的部分?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM