2017-09-19 10 views
0

続い1つの全幅行次のように私はデータテーブルを持っている: -jQueryの - のDataTable、5列行

https://jsfiddle.net/7magtdyy/1/

<div id="tabs-<?php echo $cat_inc; ?>"> 

    <table class="table-products display" cellspacing="0" width="100%"> 
     <thead> 
      <tr> 
       <th class="hidden">id</th> 
       <th>Image</th> 
       <th>Short Title</th> 
       <th class="hidden">Description</th> 
       <th class="hidden">Cost</th> 
       <th>Quantity</th> 
       <th>Total Cost</th> 
       <th>Options</th> 
      </tr> 
     </thead> 
     <tfoot> 
      <tr> 
       <th class="hidden">id</th> 
       <th>Image</th> 
       <th>Short Title</th> 
       <th class="hidden">Description</th> 
       <th class="hidden">Cost</th> 
       <th>Quantity</th> 
       <th>Total Cost</th> 
       <th>Options</th> 
      </tr> 
     </tfoot>       

      <?php foreach($posts as $post): 

       setup_postdata($post); 

       ?> 

       <tbody> 
        <tr> 
         <td class="hidden"><?php the_ID(); ?></td> 
         <td><span class="product-image" style="background:url(<?php the_field('image'); ?>);"></span></td> 
         <td><?php the_field('short_title'); ?></td> 
         <td class="hidden"><?php the_field('description'); ?></td> 
         <td class="hidden"><?php the_field('cost_price'); ?></td> 
         <td><input class="product-quantity q<?php the_ID(); ?>" type="text" /></td> 
         <td><input class="product-total-cost c<?php the_ID(); ?>" type="text" /></td> 
         <td><input type="button" class="add-row" name="add-row" value="Add"></td> 
        </tr> 
       </tbody> 

      <?php $product_increment++; endforeach; ?> 

    </table> 

全幅行として各行を表示する方法があり、すなわち4つの列の行が続く: -

<tbody> 
    <tr> 
     <td><?php the_field('short_title'); ?></td> 
    </tr> 
    <tr> 
     <td class="hidden"><?php the_ID(); ?></td> 
     <td><span class="product-image" style="background:url(<?php the_field('image'); ?>);"></span></td> 
     <td><?php the_field('short_title'); ?></td> 
     <td class="hidden"><?php the_field('description'); ?></td> 
     <td class="hidden"><?php the_field('cost_price'); ?></td> 
     <td><input class="product-quantity q<?php the_ID(); ?>" type="text" /></td> 
     <td><input class="product-total-cost c<?php the_ID(); ?>" type="text" /></td> 
     <td><input type="button" class="add-row" name="add-row" value="Add"></td> 
    </tr> 
</tbody> 

enter image description here

私はこれをやろうとしましたが、テーブルを壊しています。カラムを定義する関数はありますか?どんな助けでも大歓迎です!

答えて

0

PHPを使用してテーブルを作成してからDatatableを初期化するため、サーバー側処理を使用するのではなく、このようにする必要があります。

<tr> 
    <td colspan="5">Full Width Row</td> 
</tr> 
+0

これはそうだと思いますが、これはDataTableでエラーが発生します。参照: ; https://jsfiddle.net/7magtdyy/2/ - "未定義の '_DT_CellIndex'プロパティを設定できません" – nsilva

関連する問題