yadcf interface change to exFilterColumn confusion

百般思念 提交于 2019-12-12 03:13:39

问题


I am upgrading the yadcf version on my site from 0.6.9 to 0.8.8. (I'm also upgrading from datatables 1.9.4 to 1.10.10)

See the 0.6.9 version at my production site and the 0.8.8 version at my sandbox site

I have updated my calls to yadcf.exFilterColumn from two calls to a single call because now the defaults take an array of pairs.

But my filtered dataset is empty when the page loads, and I need to select a gender then click all for all the data to show up.

I'm sure it's something I'm not quite getting for the new interface.

Update: Simplified sandbox version here. See file TestStandings.js

Update 2: Daniel pointed out that "-1" for gender filter won't work. Apparently usegender = "-1" doesn't behave the same way in 0.8.8 as it did in 0.6.9 for some reason. I could try to figure out why it used to work, but that seems unproductive.

I added the following code after the exFilterColumn call (it's necessary for the gender to be filtered in some use cases)

    // reset gender column if didn't mean to filter
    if (usegender == "-1") {
        yadcf.exResetFilters( _rrwebapp_table, [genderCol] )
    }

but this gets exception at line 3624 of jquery.dataTable.yadcf.js because settingsDt.aanFeatures.f is undefined

Update 3: while debugging on the datatables side, I changed sDom from '<"H"Clpr>t' to the default 'lfrtip'. The exception mentioned above went away and the table loaded properly.


回答1:


Here is how you should handle your scenario

Its wrong to ask for filtering for a -1 value because there is no such value in the table, so in order to reset a specific column just before calling exFilterColumn you should use the exResetFilters with noRedraw set to true (grab from 0.8.9.beta.31) you should call this function before your exFilterColumn


Old answer

I might have noticed multiple calls to the exFilterColumn for the same table, while in fact you should call it only once, just set the desired values for each column of the table,

See showcase page (first table)

And notice the relevant code below

yadcf.exFilterColumn(firstTable, [
    [1, {
        from: 1,
        to: 40
    }],
    [3, "a_value"]
]);

If it still no goodm please provide the your table / yadcf init code and the code for calling the exFilterColumn


Update:

I noticed that your are using the following line of code

yadcf.exFilterColumn(_rrwebapp_table, [[divisionCol, usedivision], [genderCol, usegender]])

Where your usegender is set to "-1" which makes no sense, because its the value of the Select input reset option, so make sure you dont use "-1" as values in your exFilterColumn calls...



来源:https://stackoverflow.com/questions/34213024/yadcf-interface-change-to-exfiltercolumn-confusion

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!