Adrian
Adrian

Reputation: 2656

YADCF initial select latest value

I woud like to select the first value from YADCF selector at page load. I can do this manually:

yadcf.exFilterColumn(oTable, [
    // 1 being the column number, and "value" being the value you want it to initially search for when page loads
    [4, "3/2020"]

...but it is possible to automatically select the most recent value (3/2020 in the example)?

enter image description here

Upvotes: 0

Views: 195

Answers (1)

Daniel
Daniel

Reputation: 37061

You can use the 0.9.4.beta.37

yadcf.initOnDtXhrComplete(function() { 
    yadcf.exFilterColumn(oTable, [[4, $("#yadcf-filter--mytable-4 option:eq(1)").val()]], true); 
    //third argument is true so that the filter will happen immediately
});

Here is the docs for the initOnDtXhrComplete

  • initOnDtXhrComplete Description: Allows to set a callback function to be called after dt xhr finishes Arguments: function to do some logic Usage example: yadcf.initOnDtXhrComplete(function() { $("#yadcf-filter--example-0").multiselect('refresh'); });

See working fiddle

Upvotes: 2

Related Questions