yadcf icon indicating copy to clipboard operation
yadcf copied to clipboard

yadcf_data not used if Datatables has already requested the data from the server

Open mjl321 opened this issue 4 years ago • 1 comments

If YADCF is initialised after Datatables, the dropdowns only contain the values on the first page.

E.g. https://jsfiddle.net/7wv928xc/1/ only has "Red" in the second column's filter, but https://jsfiddle.net/7wv928xc/2/ correctly has "Blue" and "Green" in the list too.

Most of the time this isn't an issue, as DataTables is slow enough to initialise that YADCF adds the event handler before the first ajax request. However if YADCF is added sometime after Datatables is setup, or if Datatables is quick to initialise, then the event handler (below) is only added after the first ajax request (subsequent requests work fine).

$(document).off('xhr.dt', oTable.selector).on('xhr.dt', oTable.selector, function (e, settings, json) {

mjl321 avatar Sep 21 '20 14:09 mjl321

This is the Datatables problem. You can call this.api().ajax.reload() at the end of the init callback after yadcf initialization to make another request, which will be caught by yadcf.

dzaporozhchenko avatar Jul 07 '22 11:07 dzaporozhchenko