vedmack / yadcf

Yet Another DataTables Column Filter (yadcf)
http://yadcf-showcase.appspot.com/
MIT License
732 stars 285 forks source link

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

Open mjl321 opened 3 years ago

mjl321 commented 3 years ago

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) {

dzaporozhchenko commented 1 year ago

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.