"use strict"; // Class definition var KTAppsEducationSchoolLibrary = function() { // Private functions // basic demo var _demo = function() { var datatable = $('#kt_datatable').KTDatatable({ // datasource definition data: { type: 'remote', source: { read: { url: HOST_URL + '/api/datatables/demos/default.php', }, }, pageSize: 10, // display 20 records per page serverPaging: true, serverFiltering: true, serverSorting: true, }, // layout definition layout: { scroll: false, // enable/disable datatable scroll both horizontal and vertical when needed. footer: false, // display/hide footer }, // column sorting sortable: true, // enable pagination pagination: true, // columns definition columns: [ { field: 'CompanyName', title: 'Book', width: 250, template: function(data) { var number = KTUtil.getRandomInt(1, 13); var img = number + '.png'; var output = ''; var genreIndex = KTUtil.getRandomInt(1, 4); var genre = { 1: {'title': 'Fiction'}, 2: {'title': 'Drama'}, 3: {'title': 'Classic'}, 4: {'title': 'Thriller'} }; output = '
\
\ photo\
\
\ ' + data.CompanyName + '\
' + genre[genreIndex].title + '
\
\
'; return output; } }, { field: 'CompanyAgent', title: 'Author', template: function(row) { var output = ''; output += '' + row.CompanyAgent + ''; return output; } }, { field: 'IssueDate', title: 'Issued', type: 'date', width: 100, format: 'MM/DD/YYYY', template: function(row) { var output = ''; var status = { 1: {'title': 'New', 'class': ' label-light-primary'}, 2: {'title': 'Good', 'class': ' label-light-danger'}, 3: {'title': 'Demaged', 'class': ' label-light-primary'} }; var index = KTUtil.getRandomInt(1, 3); output += '
' + row.ShipDate + '
'; output += '
' + status[index].title + '
'; return output; }, }, { field: 'Status', title: 'Status', autoHide: false, width: 100, // callback function support for column rendering template: function(row) { var index = KTUtil.getRandomInt(1, 4); var status = { 1: {'title': 'Available', 'class': ' label-light-primary'}, 2: {'title': 'In Use', 'class': ' label-light-danger'}, 3: {'title': 'No Stock', 'class': ' label-light-info'}, 4: {'title': 'Arriving', 'class': ' label-light-success'} }; return '' + status[index].title + ''; }, }, { field: 'Actions', title: 'Actions', sortable: false, width: 130, overflow: 'visible', autoHide: false, template: function() { return '\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ '; }, }], }); $('#kt_datatable_search_status').on('change', function() { datatable.search($(this).val().toLowerCase(), 'Status'); }); $('#kt_datatable_search_type').on('change', function() { datatable.search($(this).val().toLowerCase(), 'Type'); }); //$('#kt_datatable_search_status, #kt_datatable_search_type').selectpicker(); }; return { // public functions init: function() { _demo(); }, }; }(); jQuery(document).ready(function() { KTAppsEducationSchoolLibrary.init(); });