1

arbeiten ich die follwing Version von Datentabellen bin mit:Datentabellen - Kann nicht bekommen Editor

 <script src="https://cdn.datatables.net/r/bs-3.3.5/jqc-1.11.3,dt-1.10.8/datatables.min.js"></script> 

Und die folgende Version von Editor, Buttons und wählen:

<script type="text/javascript" src="/jquery/Editor-PHP-1.5.5/js/dataTables.editor.js"></script> 
    <script src="https://cdn.datatables.net/buttons/1.1.2/js/dataTables.buttons.min.js"></script> 
    <script src="https://cdn.datatables.net/select/1.1.2/js/dataTables.select.min.js"></script> 

Dies ist meine js-Datei, die ruft meine API auf und liest in Datatables und Editor ein:

var editor; // verwende ein globales Element für das Senden und das Rendern von Daten in den Beispielen

});

Das ist mein HTML ist:

<table id="list_blogs_table" class="table table-hover table-striped table-bordered"> 
        <thead> 
         <tr> 
          <th>Id</th> 
          <th>Title</th> 
          <th>Article Text</th> 
          <th>entry_date</th> 
          <th>Status</th> 
          <th>Created</th> 
          <th>Updated</th> 

         </tr> 
        </thead> 
        <tfoot> 
          <th>Id</th> 
          <th>Title</th> 
          <th>Article Text</th> 
          <th>entry_date</th> 
          <th>Status</th> 
          <th>Created</th> 
          <th>Updated</th> 
        </tfoot> 
        <tbody> 
        </tbody> 
       </table> 

Hier ist meine JSON-Datei

{ 
"status": "success", 
"message": [{ 
    "entry_id": "1", 
    "entry_name": "12345678", 
    "entry_body": "this is just the beginning update", 
    "entry_date": "2016-05-02 20:13:12", 
    "status": "active", 
    "created_timestamp": "2016-05-01 21:25:51", 
    "updated_timestamp": "2016-05-01 21:25:51" 
}, { 
    "entry_id": "2", 
    "entry_name": "one one one", 
    "entry_body": "this is just the beginning update 1", 
    "entry_date": "2016-05-02 20:13:16", 
    "status": "active", 
    "created_timestamp": "2016-05-02 14:44:03", 
    "updated_timestamp": "2016-05-01 21:25:51" 
}, 
    [snip] 

Leider (haben es verkürzt), erhalte ich eine Tabelle ohne Daten wie folgend enter image description here

Antwort

0

Ich habe die Lösung gefunden. Hier ist der überarbeitete Code. Dumm über Dinge schauen.

 $('#list_blogs_table').DataTable({ 
    dom: "Bfrtip", 

    "ajax": { 
     "url": "http://www.example.com/api/v1/blog/blogs/format/json", 
     "dataSrc": "message", 
    }, 

    columns: [ 
     { data: "entry_id" }, 
     { data: "entry_name" }, 
     { data: "entry_body" }, 
     { data: "entry_date" }, 
     { data: "status" }, 
     { data: "created_timestamp" }, 
     { data: "updated_timestamp" }, 
    ], 
    select: true, 
    buttons: [ 
     { extend: "create", editor: editor }, 
     { extend: "edit", editor: editor }, 
     { extend: "remove", editor: editor } 
    ] 
}); 
Verwandte Themen