MVC core datatablejs ajax server side
Dear team,
please note that we facing an issue with metronic version 8 (.net core version) with datatablejs ajax server side example, the issue is the dropdownlist inside the datatablejs is not working at all and once we click on it it's not open or working at all (and it's working only on your documentation parts and we take the same code and put it on our js and its not working at all)
-
we refer for this demo steps (https://preview.keenthemes.com/html/metronic/docs/general/datatables/server-side)
-
and this one its not open and not working
{
targets: -1,
data: null,
orderable: false,
className: 'text-end',
render: function (data, type, row) {
return `
Actions
`;
},
}
Replies (3)
Dear Lauris,
Thank you for your reply and for your support.
Actually, I already added both scripts to the main layout, and the droplist not working.
I guess the problem is with the responsive option in the datatable, I tried to set this property to false and it was working, but we need the datatable to be responsive on the server side.
This is my jquery datatable (for your reference)
////////////////////////////////////////////////////////////////////////
var table;
$(document).ready(function () {
table = $("#tblCars").DataTable({
processing: true, // for show progress bar
serverSide: true, // for process server side
pageLength: 10,
responsive: true,
order: [],
buttons: [
'print',
'excelHtml5'
],
ajax: {
url: '/Cars/LoadDataCarsForPricingList',
method: "POST"
},
columns: [
{
data: 'createdDate', title: "Entry Date",
"render": function (value) {
if (value === null) return "";
return moment(value).format('DD/MM/YYYY');
}
},
{ data: 'carMakerName', title: "Maker" },
{ data: 'carModelName', title: "Model" },
{ data: 'carGradeName', title: "Grade" },
{ data: 'carGradeFuel', title: "Fuel" },
{ data: 'plateNo', title: "plate" },
{ data: 'totalCylinder', title: "Cylinder" },
{ data: 'totalkilo', title: "total kilo" },
{ data: 'exteriorColor', title: "exterior Color" },
{ data: 'insideColor', title: "inside Color" },
{ data: 'fabricType', title: "fabric" },
{ data: 'sellingType', title: "Type" },
{ data: 'showRoomPrice', title: "Price" },
{ data: 'showRoomFinalPrice', title: "FinalPrice" },
{ data: 'carOptions', title: "Options", width: 150 },
{ data: 'carRemarks', title: "Remarks", width: 150 },
{ data: 'companyName', title: "company Name" },
{ data: 'additionsPrice', title: "additions Price" },
{ data: 'createdBy', title: "created By" },
{
data: "pK_CarDetailsId"
},
],
columnDefs: [
{
targets: -1,
data: null,
orderable: false,
className: 'text-end',
render: function (data, type, row) {
return `
Actions
`;
},
}
],
// Set rows IDs
rowId: function (a) {
return a.pK_CarDetailsId;
},
"createdRow": function (row, data, dataIndex) {
const carSold = data['isSold'];
if (carSold) {
$(row).css("background-color", '#f5837d');
}
},
"language": {
search: 'search',
searchPlaceholder: '',
"emptyTable": "No Data To Display"
}
})
});
Hi,
Sorry for the late reply.
We checked an example in the latest asp.net-core version and it should work fine. The only problem you might face is with hostUrl variable which is not included by default.
You should set hostUrl in Starterkit/Views/Layout/Master.cshtml.
<script>var hostUrl = "/assets";</script> The menus are initialized globally in file js/components/menu.js, if you didn't modify anything in our codebase then an edit menu should be working as well.
Do other menu instances work in your version?
Regards,
Lauris Stepanovs,
Keenthemes Support Team
Hi,
Do you have any errors in your browser console?
Make sure that you included "datatables" vendor and your js file on your page view.
KTTheme.addVendor("datatables");
KTTheme.addJavascriptFile("js/widgets.bundle.js"); Regards,
Lauris Stepanovs,
Keenthemes Support Team