Anand
Anand

Reputation: 707

How to display the work "Search" before the search field in datatable jquery and bootstrap

I am using bootstrap datatable feature to display the table in the screen. For some reason, the word SEARCH is not shown before the search field. I do not know where I am wrong. After research, I found a way to add the word by adding the following line oLanguage":{"sSearch": "Search"} to the table property in javascript.

The fix worked for one table, but not for the other. Question is:

  1. What is the way to show the word by default?
  2. Why is it not working for other table?

Code Snippet:

$('#myTable').dataTable( {
    "bProcessing": true,
    "bAutoWidth": true,
    "sAjaxSource": "../data/myStruts.action",
    "sAjaxDataProp": "",
    "bPaginate": true,
    "bInfo":false,      
    "aoColumns": [
        {"mData":"userID"},
        {"mData":"currentQueue"},
        {"mData":"transactionDate"},
        {"mData":"postingDate"}
    ],
"oLanguage":{"sSearch": "Search"}
});

Upvotes: 1

Views: 883

Answers (2)

Anand
Anand

Reputation: 707

Thanks everyone for answering my questions...

I did some more research on datatable and found out that the default values provided by bootstrap-datatables were modified.The oLanguage attribute of datatable has the ability to customize your word. Initially, the value for sSearch was bland and I change it to Search. Now, wherever I use the datatable, the search keyword appears without adding any extra line in the respective JS. Below is an extra of bs3.datatables.js

(function ($) {
/* Set the defaults for DataTables initialisation */
$.extend( true, $.fn.dataTable.defaults, {
    "sDom": "<'row'<'col-sm-12'<'pull-right'f><'pull-left'l>r<'clearfix'>>>t<'row'<'col-sm-12'<'pull-left'i><'pull-right'p><'clearfix'>>>",
    "sPaginationType": "bs_normal",
    "oLanguage": {
        "sLengthMenu": "Show _MENU_ Rows",
        "sSearch": "Search"
    }
} );

Upvotes: 2

BENARD Patrick
BENARD Patrick

Reputation: 30995

In following the doc I hope it will work...

The doc : http://datatables.net/reference/option/language.search

Extract :

$('#example').dataTable( {
  "language": {
    "search": "Filter records:"
  }
} );

Upvotes: 0

Related Questions