2016-09-19 90 views
0

如何将rowspan添加到不可过滤列的ng-table-dynamic标头中?如果没有过滤器,则使用ng-table header rows rowspan

enter image description here 这个例子的代码可以在http://codepen.io/ike3/pen/wzzgzG

找到我要的是设置rowspan="2"年龄和金钱th的。看起来我可以为头和过滤器创建自定义模板,但无法控制表结构本身。

+0

你试过http://ng-table.com/#/filtering/demo-multi-template – hurricane

+0

它似乎允许通过“colspan”来组合单元格,而不是行。我想将Money标题与空过滤单元结合使用。那可能吗? – ike3

回答

0

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

自定义过滤器模板:

<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"); 
     } 
    }; 
}) 

也许有更好的办法。

相关问题