/**
* app-ecommerce-order-details Script
*/
'use strict';
// Datatable (jquery)
$(function () {
// Variable declaration for table
var dt_details_table = $('.datatables-order-details');
// E-commerce Products datatable
if (dt_details_table.length) {
var dt_products = dt_details_table.DataTable({
ajax: assetsPath + 'json/ecommerce-order-details.json', // JSON file to add data
columns: [
// columns according to JSON
{ data: 'id' },
{ data: 'id' },
{ data: 'product_name' },
{ data: 'price' },
{ data: 'qty' },
{ data: '' }
],
columnDefs: [
{
// For Responsive
className: 'control',
searchable: false,
orderable: false,
responsivePriority: 2,
targets: 0,
render: function (data, type, full, meta) {
return '';
}
},
{
// For Checkboxes
targets: 1,
orderable: false,
checkboxes: {
selectAllRender: ''
},
render: function () {
return '';
},
searchable: false
},
{
// Product name and product info
targets: 2,
responsivePriority: 1,
searchable: false,
orderable: false,
render: function (data, type, full, meta) {
var $name = full['product_name'],
$product_brand = full['product_info'],
$image = full['image'];
if ($image) {
// For Product image
var $output =
'';
} else {
// For Product badge
var stateNum = Math.floor(Math.random() * 6);
var states = ['success', 'danger', 'warning', 'info', 'dark', 'primary', 'secondary'];
var $state = states[stateNum],
$name = full['product_name'],
$initials = $name.match(/\b\w/g) || [];
$initials = (($initials.shift() || '') + ($initials.pop() || '')).toUpperCase();
$output = '' + $initials + '';
}
// Creates full output for Product name and product_brand
var $row_output =
'