Multiple endpoints in dependent() method
Multiple endpoints in dependent() method
scturnbull
Posts: 2Questions: 1Answers: 0
Hi All,
I'm new to DataTables/Editor so apologies if I'm asking the obvious however, I cannot see any examples where different endpoints are called dependent on the value of a dropdown. All I've seen to date are the following examples.
editor.dependent( 'options', function ( val ) {
return val === 'Simple' ?
{ hide: ['position', 'office', 'extn', 'start_date', 'salary'] } :
{ show: ['position', 'office', 'extn', 'start_date', 'salary'] };
} );
editor.dependent( 'continent', '/api/countries' );
Therefore, is it possible? I’ve tried adding a case statement and returning a string but to no avail.
This question has an accepted answers - jump to answer
Answers
Yes - you'd need to use a function (e.g. the first of the two examples you posted) and in there do a conditional check on the value and then make the corresponding Ajax request - e.g.:
In the
success
callback for each Ajax call, make sure you call thecallback()
function with the data you want to update, as described independent()
.Allan
Thanks Allan, Works like a charm!