Hi,
I load page-specific javascript files as follows.
<script suppress-error="BL9992" src="@KTTheme.GetAssetPath("zcustom/js/datatable.init.js")"></script>
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await js.InvokeAsync<IJSObjectReference>("TestDataTablesAdd", "#kt_datatable_example"); //line 473
}
}
function TestDataTablesAdd(tableName/*, jsonData, jsonColumns*/) {
$(document).ready(function () {
var table = document.querySelector(tableName);
$(table).DataTable({
//"data": jsonData,
//"columns": jsonColumns,
"fixedHeader": {
"header": true,
"headerOffset": 73
},
columnDefs: [
{ orderable: false, targets: 0 },
{ orderable: false, targets: 1 },
{ "visible": false, "targets": 1 }
],
order: [[2, "asc"]],
"scrollX": true,
//"responsive": true,
"info": false,
"pageLength": 10,
"select": true,
"select": {
style: "multi",
selector: "td:first-child input[type="checkbox"]",
className: "row-selected"
}
});
});
}
function TestDataTablesRemove(tableName) {
$(document).ready(function () {
var table = document.querySelector(tableName);
$(table).DataTable().destroy();
// Removes the datatable wrapper from the dom.
var elem = document.querySelector(table + "_wrapper");
elem.parentNode.removeChild(elem);
});
}
Hi,
Thank you for reaching out to us.
You can try adding your functions to the window scope like this:
window.TestDataTablesAdd = TestDataTablesAdd;
window.TestDataTablesRemove = TestDataTablesRemove;
Hi,
It worked this way, thank you.
Hi,
Glad to hear that. All the best with your project!
Please don't hesitate to reach out if you need anything more from us.
Regards,
Lauris Stepanovs,
Keenthemes Support Team