DataTables的精确搜索功能实现(Lightning Aura Component)

doSearch: function (component, event, helper) {

        let tableElem = component.find("myTable").getElement();
        let table = $(tableElem).DataTable({ "retrieve": true });
        let searchResult = table.search('');

        let f1 = component.get("v.filter1");
        if (f1.length > 0) {
            f1 = f1.replace('\(', '\\(').replace('\)', '\\)');
            searchResult = searchResult.column(8).search('^' + f1 + '$', true, false);
        } else {
            searchResult = searchResult.column(8).search('');
        }

        let f2 = component.get("v.filter2");
        if (f2.length > 0) {
            f2 = f2.replace('\(', '\\(').replace('\)', '\\)');
            searchResult = searchResult.column(12).search('^' + f2 + '$', true, false);
        } else {
            searchResult = searchResult.column(12).search('');
        }

        let f3 = component.get("v.filter3");
        if (f3.length > 0) {
            searchResult = searchResult.column(2).search('^' + f3 + '$', true, false);
        } else {
            searchResult = searchResult.column(2).search('');
        }

        let f4 = component.get("v.filter4");
        if (f4.length > 0) {
            searchResult = searchResult.column(0).search(f4);
        } else {
            searchResult = searchResult.column(0).search('');
        }

        searchResult.draw();  
}  

 

上一篇:打印Fibonacci(斐波那契)数


下一篇:ABB AC 900F学习笔记77:Freelance_Mounting_and_Installation_AC_900F_Controller-37