Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getUserList(){
- var html = "";
- html += "<table id='datatable-buttons' class='table table-striped table-bordered dt-responsive nowrap'";
- html += "style='border-collapse: collapse; border-spacing: 0; width: 100%;'>";
- html += "<thead>";
- html += "<tr>";
- html += "<th>Book Code</th>";
- html += "<th>Book Name</th>";
- html += "<th>Book Creator</th>";
- html += "<th>Book Publisher</th>";
- html += "<th>Book Quantity</th>";
- html += "<th>Book Receive Date</th>";
- html += "<th>Book Note</th>";
- html += "<th>Book Category</th>"
- html += "</tr>";
- html += "</thead>";
- html += "</table>";
- $("#bookListDT").html(html);
- $("#datatable-buttons").DataTable({
- dom: 'Bfrtip',
- ajax : {
- type : "GET",
- url : "getBookList",
- dataSrc : function (json) {
- var return_data = new Array();
- for(var i=0;i<json.length; i++){
- return_data.push({
- 'bookCode' : json[i].bookCode,
- 'bookName' : json[i].bookName,
- 'bookCreator' : json[i].bookCreator,
- 'bookPublisher' : json[i].bookPublisher,
- 'bookQuantity' : json[i].bookQuantity,
- 'bookReceiveDate' : json[i].bookReceiveDate,
- 'bookNote' : json[i].bookNote,
- 'booksCategory' : json[i].booksCategory.categoryName,
- })
- }
- return return_data;
- }
- },
- columns : [
- {data: 'bookCode'},
- {data: 'bookName'},
- {data: 'bookCreator'},
- {data: 'bookPublisher'},
- {data: 'bookQuantity'},
- {data: 'bookReceiveDate'},
- {data: 'bookNote'},
- {data: 'booksCategory'}
- ],lengthChange:!1,buttons:[
- {
- extend: 'print',
- exportOptions: {
- columns: [ 0, 1, 2, 3, 4, 5, 6 ]
- }
- },
- {
- extend: 'excel',
- exportOptions: {
- columns: [ 0, 1, 2, 3, 4, 5, 6 ]
- }
- },
- {
- extend: 'csv',
- exportOptions: {
- columns: [ 0, 1, 2, 3, 4, 5, 6 ]
- }
- },
- 'colvis'
- ]
- }).buttons().container().appendTo("#datatable-buttons_wrapper .col-md-6:eq(0)");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement