2016-03-31 11 views
1

jsデータ型を介してエンティティを表示しようとしています。私はiDisplayLengthを10に設定していますが、すべての行が表示されます。Jquery Datatablesはdisplaylengthで行をフィルタリングしません。

私はDataTableの1.10.10

JSを使用します。それが動作しない理由を

var settings = { 
     bAutoWidth: false, 
     autoWidth: false, 
     serverSide: true, 
     processing: true, 
     bLengthChange: true, 
     iDisplayLength: 10, 
     destroy: true, 
     scrollCollapse: true, 
     bLengthChange: true, 
     ajax: { 
      url: '/service/op', 
      type: 'POST', 
      dataSrc: 'data.posts', 
      data: function (d) { 
       d.op = 'datatable'; 
       d.sub_op = '@table_api'; 
       return JSON.stringify(d) 
      } 
     }, 
     sDom: "<'table-responsive't><'row'<p i>>", 
     columns: [ 
      { 
       render: function (data, type, link) { 
        return "shitttt" 
       } 
      } 
     ], 

    }; 

    var dt = $("#[email protected]_page").DataTable(settings); 

HTML

<div class="row"> 
    <div class="col-md-10 col-vlg-7"> 
     <table class="monitoring_timeline" id="[email protected]_page"> 
      <thead> 
       <tr> 
        <th></th> 
       </tr> 
      </thead> 
      <tbody> 

      </tbody> 
     </table> 
    </div> 
</div> 

を誰もが知っています。

JSON:

{ 
    "draw": 1, 
    "recordsTotal": 1515, 
    "recordsFiltered": 1, 
    "data": { 
     "posts": [{ 
      "id": -7840784480314929507, 
      "datetime": "\/Date(1459359970000)\/", 
      "day_str": "today", 
      "time_str": "10.00 pm", 
      "user_name": "Clarice", 
      "user_profile_pic": "http://pbs.twimg.com/profile_images/714612662265651200/pbe_pnec_normal.jpg", 
      "sentiment": 2, 
      "title": "N tem nd pior q criar expectativas e se decepcionar!!! Arrrgh", 
      "content": "N tem nd pior q criar expectativas e se decepcionar!!! Arrrgh", 
      "lang": "pt", 
      "media": false, 
      "media_type": 0, 
      "media_src": null, 
      "iframe": false, 
      "comments": null, 
      "reactions": null, 
      "reposts": null, 
      "crm": false, 
      "topic": 0, 
      "category": { 
       "1": 1, 
       "2": 2, 
       "3": 1 
      } 
     }, { 
      "id": -3529972708747955425, 
      "datetime": "\/Date(1459359970000)\/", 
      "day_str": "today", 
      "time_str": "10.00 pm", 
      "user_name": "Um tal de Fernando", 
      "user_profile_pic": "http://pbs.twimg.com/profile_images/714705253191561216/Gn64mC-l_normal.jpg", 
      "sentiment": 2, 
      "title": "1 mês que não sei o que é escola", 
      "content": "1 mês que não sei o que é escola", 
      "lang": "pt", 
      "media": false, 
      "media_type": 0, 
      "media_src": null, 
      "iframe": false, 
      "comments": null, 
      "reactions": null, 
      "reposts": null, 
      "crm": false, 
      "topic": 0, 
      "category": { 
       "1": 1, 
       "2": 2, 
       "3": 1 
      } 
     }] 
    } 
} 

答えて

1

あなたがrender機能を使用する場合、あなたは列のdataを指定する必要があります。 https://jsfiddle.net/cmedina/7kfmyw6x/34/

:次のようになりますあなたの場合は

....

columns: [ 
      { 
      data : "op", 
      render: function (data, type, link) { 
       return "shitttt" 
      } 
     ] 

チェックアウトこの例では、サーバー側

例を除いて、あなたと同じ構成を有しています更新

サーバーはを返す必要がありますあなたのページングのための!

"draw": 1, 
"recordsTotal": 1515, 
"recordsFiltered": 1,//Total records, after filtering (i.e. the total number of records after filtering has been applied - not just the number of records being returned for this page of data). 
+0

あなたのコードはデータ行を削除するときに機能します。 – RockOnGom

+0

そして私もそれを試してもうまくいきませんでした。 – RockOnGom

+0

はい、はいですが、レンダリングが必要な列を指定する必要があります。それ以外の場合は、 'mData' @RockOnGomのエラーが表示されます – CMedina

関連する問題