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();  
}  

 

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

上一篇:面经分享 | B站 | 数据分析 | 2021.1


下一篇:IoT边缘,你究竟是何方神圣?