简体   繁体   中英

Datatables YADCF error reseting all column (exResetAllFilters)

I'm using YADCF plugin for datatables and I'm using exResetAllFilters to reset all column filters but it doesn't work.

I have done an example using Jsfiddle. Using Firebug I can see the error:

TypeError: string is undefined

return string.replace(new RegExp(escapeRegExp(find), 'g'), replace);

I have changed this function in the YADCF library and also generateTableSelectorJQFriendly to check if string is empty.

function replaceAll(string, find, replace) {
    if (string) {
        return string.replace(new RegExp(escapeRegExp(find), 'g'), replace);
    }
    else {
        return string;
    }
}

function generateTableSelectorJQFriendly(tmpStr) {
    if (tmpStr) {
        tmpStr = replaceAll(tmpStr, ".", "-");
        tmpStr = replaceAll(tmpStr, ' ', '');
        return tmpStr.replace(":", "-").replace("(", "").replace(")", "").replace("#", "-");
    }
    else {
        return tmpStr
    }
}

After these changes I see a different error

TypeError: table_arg.fnDraw is not a function

table_arg.fnDraw(settingsDt);

How can I fix it?

The issue in jsfiddle was just a jsfiddle issue related to its wrapping way ,

I have solved it by using .click instead of dom onclick (I did so only because its jsfiddle - in a normal web app you can use onclick without any problems) , see working jsfiddle , if you have any other issue that can be reproduced feel free to ask

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM