2016-07-29 4 views
0

あるのjQueryのDataTable列検索の場合は、これは私のシナリオ

$('#invoicesDataTable thead th').each(function() { 
      var title = $(this).text(); 
      $(this).html('<input type="text" style="width:100%;" placeholder="' + title + '" />'); 
     }); 

     invoicesDataTable.columns().every(function() { 
      var that = this; 
      $('input', this.header()).on('keyup change', function() { 
       if (that.search() !== this.value) 
        that.search(this.value, false, true, true).draw(); 
      }); 
     }); 
:私はこのように各列に検索、追加初期化後

invoicesDataTable = $('#invoicesDataTable').DataTable({ 

       processing: true, 
       serverSide: true, 
       searchDelay: 1000, 
       search: { 
        caseInsensitive: true 
       }, 
       ajax: { 
        type: 'GET', 
        url: '{!! route("admin.invoice.filterData") !!}', 
        dataSrc: function (response) { 
         return response.data; 
        } 
       }, 
//    aLengthMenu: [ [ 50, 100, 150, 200, -1 ], [ 50, 100, 150, 200, 'All' ] ], 
       columns: [ 
        {data: 'document_number', name: 'invoices.document_number', orderable: false}, 
        {data: 'document_type', name: 'invoices.document_type', orderable: false}, 
        {data: 'tax_regime', name: 'invoices.tax_regime', orderable: false}, 
        {data: 'auction_id', name: 'auctions.auction_id', orderable: false}, 
        {data: 'business_name', name: 'customers.business_name', orderable: false}, 
        {data: 'total_amount', name: 'invoices.total_amount', orderable: false}, 
        {data: 'datetime_invoice', name: 'invoices.datetime_invoice', orderable: false}, 
        {data: 'actions', name: 'actions', orderable: false, searchable: false} 
       ], 
      }); 

大文字と小文字を区別しない検索以外は正しく動作します。私が "John"のような価値のある列を持っていて、 "john"を検索すると、 "John"という行が表示されません。それを動作させる方法はありますか? (大文字小文字の区別がない場合は、グローバル検索が完全に機能します)

+0

あなたのコードは正常に動作し、参照https://jsfiddle.net/aL3f4w9n/ –

答えて

0

大文字か小文字かを比較してください。正しい答えではありません

例:。:

if (that.search().toLowerCase() !== this.value.toLowerCase()) 

または

if (that.search().toUpperCase() !== this.value.toUpperCase()) 
+0

、この行のみになりテキストボックスの値が変更されていることを確認してください。 –

関連する問題