无法在Jquery Datatable中实现完全匹配

时间:2019-03-29 04:07:16

标签: jquery datatable

我正在尝试在数据表中实现精确搜索。目前,我正在从另一个Jquery函数将值传递给“搜索”字段。这工作得很好。现在,我试图在数据表中实现“精确搜索”。

我也尝试过以下链接-

JQuery DataTable - Search for exact match

DataTables column search for exact match

这是我的代码块

    <table id="q2" class="display" style="width:200%">
    <thead>
        <tr>
            <th>Schema</th>
            <th>Table Name</th>
            <th>Last Update Time</th>
            <th>Last Update Job</th>
            <th>Update Responsible</th>
            <th>Table Type ID</th>
            <th>Table Usage ID</th>
            <th>Row Update ID</th>
            <th>Table Comment</th>
            <th>Table Source ID</th>
            <th>Connected</th>
            <th>User View</th>
            <th>Imaginary</th>
            <th>User Table Comment</th>
            <th>BI Service</th>
            <th>Business Owner</th>
            <th>Solution Owner</th>
        </tr>
    </thead>
    </table>


  $(document).ready(function () {
    var query = getUrlVars()["query"];
        var table = $('#q2').removeAttr('width').dataTable({
            "search": {"search": query, 
                        "regex": false,
                        "smart": false},
            "ordering": true,
            "language": {"zeroRecords": "No records to display"},
            ajax: 'logapi.php?query=query_02',
            fixedHeader: true,
            deferRender: true,
            scroller: true,
            processing: 'Loading...',
            autowidth: true,
            responsive: false,
            orderClasses: false,
            columnDefs: [{ width: 100, targets: 0 }],
            fixedColumns: true

        }).yadcf([
            { column_number: 0 },
            { column_number: 1 },
            { column_number: 2 },
    { column_number: 3 },
            { column_number: 4 },
            { column_number: 5 },
            { column_number: 6 },
            { column_number: 7 },
            { column_number: 8 },
            { column_number: 9 },
            { column_number: 10 },
            { column_number: 11 },
            { column_number: 12 },
            { column_number: 13 },
            { column_number: 14 },
            { column_number: 15 },
            { column_number: 16 }

        ]);
        table
    .column(1).search("(^"+query+"$)",true,false)
    .draw();

    });

但是在尝试将值“ ART_SUP_PACK”传递到搜索字段时,它返回的两行包含“ ART_SUP_PACK”和“ ART_SUP_PACK_V”,即精确搜索无法按预期进行。

我在这里做错了什么?我想念什么吗?

0 个答案:

没有答案