2016-09-19 9 views
0

フィルタリング不可能な列のng-table-dynamicヘッダーにrowspanを追加するにはどうすればよいですか?フィルタがない場合の角度ngテーブルのヘッダー行スパン

enter image description here この例のコードは、私が欲しいのは、年齢やマネーthのためrowspan="2"を設定することですhttp://codepen.io/ike3/pen/wzzgzG

で見つけることができます。私はヘッダーとフィルターの両方のカスタムテンプレートを作成することができますが、テーブル構造自体を制御することはできないようです。

+0

あなたは試しましたか?http://ng-table.com/#/filtering/demo-multi-template – hurricane

+0

それは 'colspan'でセルを組み合わせることができますが、行には使用できません。私は空のフィルターセルとマネーヘッダーを結合したい。それは可能ですか? – 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"); 
     } 
    }; 
}) 

たぶんもっと良い方法があります。

関連する問題