call public function with initComplete
call public function with initComplete
Hi,
iam looking for a way to call a public function after my DataTable is done with loading the Data from ajax.
Thought initComplete might be the solution. But i got "Uncaught TypeError: this.enableEverything is not a function"
Here is my Code:
private initVolumenTable() {
const url = 'resources/limitoverview/banks/loadVolumen';
const type = 'GET';
$('#volumen-table').DataTable({
ajax: {
url: url,
dataSrc: 'dhVolumenList',
contentType: "application/json",
type: type
},
columns: [
{ data: "stammnr" },
{ data: "bank" },
{ data: "maxLfz" },
{ data: "limitEur" },
{ data: "ausnutzung" },
{ data: "verfuegbar" },
{ data: "maxLimitEur" },
{ data: "maxAusnutzung" },
{ data: "maxVerfuegbar" },
],
columnDefs: [
{ targets: [3, 6], render: $.fn.dataTable.render.number('.', null, null, null, '€'), className: 'dt-body-right' },
{ targets: [4, 5, 7, 8], render: $.fn.dataTable.render.number('.', ',', 2, null, '€'), className: 'dt-body-right' },
{ targets: 2, className: 'dt-body-center' }, //TODO css klasse scheint Probleme zu haben
],
scrollY: "400px",
scrollCollapse: false,
paging: false,
ordering: true,
order: [[5, "desc"]],
searching: false,
info: false,
alwaysCloneTop: true,
language: {
zeroRecords: this.noDataFoundLabel
},
initComplete: function (settings, json) {
this.enableEverything();
},
});
}
This discussion has been closed.
Replies
What is
enableEverythinga method of?thisin theinitCompletecallback is the table node.Allan
Hi Allan,
This function just enable variables who are binded to html buttons and Datepickers.
like:
<button type="button" disabled.bind="!isUsable">in my typescript file i have to use
thisfor mostly everything.Thank you
Tom
If
enableEverythingis a standalone function then just call it withoutthis.Kevin
It doesn't look like it is since it uses
thisinside it. The syntax also appears to suggest that it is a method of a class. @TomL you need to use the variable that refers to the instance of that class -myPage.enableEverything()for example.Might be worth reading through a tutorial such as this one to understand scoping and context in Javascript.
Allan
Thanks for your answer, allan
u r right. my
InitVolumenTable()is in the same Class (Banks) like my methodenableEverything().When i try to call:
I get the typescirpt error:"Property 'enableEverything' does not exist on type 'typeofBanks'. "
But i got a ( maybe temp and not beautiful) solution:
with this i can easily call my annoying ts method on the same time like
initComplete;PTom
Have you created an instance of your class? You need to call the instance member. It is not a static function, so you can't just use
Banks.enableEverything().Allan