' +
''
);
}
}
],
order: [2, 'desc'], //set any columns order asc/desc
dom:
'<"card-header d-flex flex-wrap py-0 flex-column flex-sm-row"' +
'' +
'<"d-flex justify-content-center justify-content-md-end align-items-baseline"<"dt-action-buttons d-flex justify-content-center flex-md-row align-items-baseline"lB>>' +
'>t' +
'<"row"' +
'<"col-sm-12 col-md-6"i>' +
'<"col-sm-12 col-md-6"p>' +
'>',
lengthMenu: [7, 10, 20, 50, 70, 100], //for length of menu
language: {
sLengthMenu: '_MENU_',
search: '',
searchPlaceholder: 'Search Category',
paginate: {
next: '',
previous: ''
}
},
// Button for offcanvas
buttons: [
{
text: 'Add Category',
className: 'add-new btn btn-primary ms-2',
attr: {
'data-bs-toggle': 'offcanvas',
'data-bs-target': '#offcanvasEcommerceCategoryList'
}
}
],
// For responsive popup
responsive: {
details: {
display: $.fn.dataTable.Responsive.display.modal({
header: function (row) {
var data = row.data();
return 'Details of ' + data['categories'];
}
}),
type: 'column',
renderer: function (api, rowIdx, columns) {
var data = $.map(columns, function (col, i) {
return col.title !== '' // ? Do not show row in modal popup if title is blank (for check box)
? '
' +
'
' +
col.title +
':' +
'
' +
'
' +
col.data +
'
' +
'
'
: '';
}).join('');
return data ? $('
').append(data) : false;
}
}
}
});
$('.dt-action-buttons').addClass('pt-0');
$('.dataTables_filter').addClass('me-3 mb-sm-6 mb-0 ps-0');
}
// Filter form control to default size
// ? setTimeout used for multilingual table initialization
setTimeout(() => {
$('.dataTables_filter .form-control').removeClass('form-control-sm');
$('.dataTables_filter .form-control').addClass('ms-0');
$('.dataTables_length .form-select').removeClass('form-select-sm');
$('.dataTables_length .form-select').addClass('ms-0');
}, 300);
});
//For form validation
(function () {
const eCommerceCategoryListForm = document.getElementById('eCommerceCategoryListForm');
//Add New customer Form Validation
const fv = FormValidation.formValidation(eCommerceCategoryListForm, {
fields: {
categoryTitle: {
validators: {
notEmpty: {
message: 'Please enter category title'
}
}
},
slug: {
validators: {
notEmpty: {
message: 'Please enter slug'
}
}
}
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap5: new FormValidation.plugins.Bootstrap5({
// Use this for enabling/changing valid/invalid class
eleValidClass: 'is-valid',
rowSelector: function (field, ele) {
// field is the field name & ele is the field element
return '.mb-6';
}
}),
submitButton: new FormValidation.plugins.SubmitButton(),
// Submit the form when all fields are valid
// defaultSubmit: new FormValidation.plugins.DefaultSubmit(),
autoFocus: new FormValidation.plugins.AutoFocus()
}
});
})();