【问题标题】:Angular ng-table header rowspan if no filter如果没有过滤器,则角度 ng-table 标题行跨度
【发布时间】:2016-09-19 07:34:22
【问题描述】:

如何为不可过滤的列添加行跨度到 ng-table-dynamic 标题?

这个示例代码可以在http://codepen.io/ike3/pen/wzzgzG找到。

我只想为年龄和金钱设置rowspan="2"th。看来我可以为标题和过滤器创建自定义模板,但无法控制表结构本身。

【问题讨论】:

标签: angularjs ngtable


【解决方案1】:

我设法用 jQuery 做到了这一点,但它看起来像一个 hack:

自定义过滤器模板:

<script type="text/ng-template" id="/filters/rowspan">
    <filter-row-span></filter-row-span>
</script>

还有一个指令:

.directive('filterRowSpan', function() {
    return {
        link: function($scope, element, attrs) {
            var idx = $(element[0]).parents("th").index();
            var tbl = $(element[0]).parents(".table");
            for (var i = 0; i < idx; i++) {
                var rs = tbl.find("thead > tr:first-child th:nth-child(" + (1+i) + ")").attr("rowspan");
                if (rs) idx++;
            }
            tbl.find("thead > tr:nth-child(2) th:nth-child(" + (1+idx) + ")").remove();
            tbl.find("thead > tr:first-child th:nth-child(" + (1+idx) + ")").attr("rowspan", 2).addClass("no-filter");
        }
    };
})

也许有更好的方法。

【讨论】:

    猜你喜欢
    • 2014-12-23
    • 1970-01-01
    • 2017-02-21
    • 1970-01-01
    • 2015-09-15
    • 2015-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多