//== Class definition
var DefaultDatatableDemo = function () {
//== Private functions
// basic demo
var demo = function () {
var datatable = $('.m_datatable').mDatatable({
data: {
type: 'remote',
source: {
read: {
url: 'http://keenthemes.com/metronic/preview/inc/api/datatables/demos/default.php'
}
},
pageSize: 20,
serverPaging: true,
serverFiltering: true,
serverSorting: true
},
layout: {
theme: 'default',
class: '',
scroll: true,
height: 550,
footer: false
},
sortable: true,
filterable: false,
pagination: true,
search: {
input: $('#generalSearch')
},
columns: [{
field: "RecordID",
title: "#",
locked: {left: 'xl'},
sortable: false,
width: 40,
selector: {class: 'm-checkbox--solid m-checkbox--brand'}
}, {
field: "Actions",
width: 110,
title: "Actions",
sortable: false,
locked: {left: 'xl'},
overflow: 'visible',
template: function (row, index, datatable) {
var dropup = (datatable.getPageSize() - index) <= 4 ? 'dropup' : '';
return '\
\
\
\
\
\
\
\
';
}
}, {
field: "ShipCountry",
title: "Ship Country",
width: 150,
template: function (row) {
return row.ShipCountry + ' - ' + row.ShipCity;
}
}, {
field: "ShipCity",
title: "Ship City",
sortable: false
}, {
field: "ShipName",
title: "Ship Name",
width: 150,
responsive: {visible: 'lg'}
}, {
field: "ShipAddress",
title: "Ship Address",
width: 200,
responsive: {visible: 'lg'}
}, {
field: "CompanyEmail",
title: "Email",
width: 150,
responsive: {visible: 'lg'}
}, {
field: "CompanyAgent",
title: "Agent",
responsive: {visible: 'lg'}
}, {
field: "Notes",
title: "Notes",
width: 350
}, {
field: "Website",
title: "Website",
width: 200
}, {
field: "Currency",
title: "Currency",
width: 100
}, {
field: "Department",
title: "Department"
}, {
field: "ShipDate",
title: "Ship Date"
}, {
field: "TimeZone",
title: "Time Zone",
width: 150
}, {
field: "Status",
title: "Status",
locked: {left: 'xl'},
width: 100,
// callback function support for column rendering
template: function (row) {
var status = {
1: {'title': 'Pending', 'class': 'm-badge--brand'},
2: {'title': 'Delivered', 'class': ' m-badge--metal'},
3: {'title': 'Canceled', 'class': ' m-badge--primary'},
4: {'title': 'Success', 'class': ' m-badge--success'},
5: {'title': 'Info', 'class': ' m-badge--info'},
6: {'title': 'Danger', 'class': ' m-badge--danger'},
7: {'title': 'Warning', 'class': ' m-badge--warning'}
};
return '' + status[row.Status].title + '';
}
}, {
field: "Type",
title: "Type",
width: 150,
// 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': 'accent'}
};
return ' ' + status[row.Type].title + '';
}
}]
});
};
return {
// public functions
init: function () {
demo();
}
};
}();
jQuery(document).ready(function () {
DefaultDatatableDemo.init();
});