2016-09-12 9 views
0

私はここのグループのリストを持つページがあります。DataTablesを使用して2つの行を1つにする方法

http://liquidchurch.com/groups/groups-browse/

これはWordPress、DataTableの、そしてCCBコアAPIプラグインを使用してうまく機能しています。

説明を各グループに追加する必要がありますが、説明が長すぎてテーブルの末尾に追加できないため、別の行に表示したいが、依然として視覚的な外観と並べ替えの目的の両方で、メイン行(グループについて)。

はここに私の現在のコードです:

https://gist.github.com/davidshq/2c54fae1d3fd73bc6eda7dc537c1abed

+2

がhttps://datatables.net/examples/api/row_details.html –

+0

感謝を見てください、私はそれを見ました...私はまだこれがどのように動作するのか少し混乱しています...それについてもう少し詳しく説明する記事を見つけることが大好きです。 – davemackey

答えて

0
// set up the datatablse 
    var table = $('#example').DataTable(); 

    // list of descriptions for each person 
    var desc = { 
     "Ashton Cox": "Ashton is a baller", 
     "Cedric Kelly": "Died in the last harry potter movie", 
     "Garrett Winters": "this guy is cold af" 
    }; 

    // loop each row 
    $('#example tbody').find("tr").each(function(){ 

     // get the name which matches the keys in our 
     // descriptions, in this case it's in the first col 
     var name = $(this).find("td").eq(0).text(); 
     if(!name.length) return; 

     if(undefined === desc[name]) return; 
     table.row($(this)).child(desc[name]).show(); 

    }); 

デモ:https://jsfiddle.net/j767gs8t/1

+0

ありがとうございます。問題は、サードパーティのCCB APIを介して作成されたカスタム投稿の種類からデータを引き出すことです。私はWP_Query経由でこれを取得、私の要点(元の質問のリンク) – davemackey

関連する問題