"use strict"; // Class definition var KTDatatableColumnWidthDemo = function() { // Private functions // basic demo var demo = function() { var datatable = $('.kt-datatable').KTDatatable({ // datasource definition data: { type: 'remote', source: { read: { url: 'https://keenthemes.com/metronic/themes/themes/metronic/dist/preview/inc/api/datatables/demos/default.php', }, }, pageSize: 10, serverPaging: true, serverFiltering: false, serverSorting: true, }, // layout definition layout: { scroll: true, // enable/disable datatable scroll both horizontal and // vertical when needed. height: null, // datatable's body's fixed height footer: false, // display/hide footer }, // column sorting sortable: true, pagination: true, search: { input: $('#generalSearch'), }, // columns definition columns: [ { field: 'RecordID', title: '#', sortable: 'asc', width: 30, type: 'number', selector: false, textAlign: 'center', }, { field: 'OrderID', title: 'Order ID', }, { field: 'Country', title: 'Country', template: function(row, index, datatable) { return row.Country + ' ' + row.ShipCountry; }, }, { field: 'CompanyEmail', width: 150, title: 'Email', }, { field: 'ShipDate', title: 'Ship Date', type: 'date', format: 'MM/DD/YYYY', }, { field: 'Status', title: 'Status', // callback function support for column rendering template: function(row) { var status = { 1: {'title': 'Pending', 'class': 'kt-badge--brand'}, 2: {'title': 'Delivered', 'class': ' kt-badge--danger'}, 3: {'title': 'Canceled', 'class': ' kt-badge--primary'}, 4: {'title': 'Success', 'class': ' kt-badge--success'}, 5: {'title': 'Info', 'class': ' kt-badge--info'}, 6: {'title': 'Danger', 'class': ' kt-badge--danger'}, 7: {'title': 'Warning', 'class': ' kt-badge--warning'}, }; return '' + status[row.Status].title + ''; }, }, { field: 'Type', title: 'Type', autoHide: false, // callback function support for column rendering template: function(row) { var status = { 1: {'title': 'Online', 'state': 'danger'}, 2: {'title': 'Retail', 'state': 'primary'}, 3: {'title': 'Direct', 'state': 'success'}, }; return ' ' + status[row.Type].title + ''; }, }, { field: 'Actions', title: 'Actions', sortable: false, width: 110, overflow: 'visible', autoHide: false, template: function() { return '\ \ \ \ \ \ \ \ '; }, }], }); $('#kt_form_status').on('change', function() { datatable.search($(this).val().toLowerCase(), 'Status'); }); $('#kt_form_type').on('change', function() { datatable.search($(this).val().toLowerCase(), 'Type'); }); $('#kt_form_status,#kt_form_type').selectpicker(); }; return { // public functions init: function() { demo(); }, }; }(); jQuery(document).ready(function() { KTDatatableColumnWidthDemo.init(); });