YADCF初始select最新值

YADCF initial select latest value

我想 select 来自 YADCF select 或在页面加载时的第一个值。我可以手动执行此操作:

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"]

...但是可以自动 select 最近的值(示例中的 3/2020)?

您可以使用 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
});

这是 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