searchable not working

searchable not working

asifjee104asifjee104 Posts: 6Questions: 2Answers: 0

Actually i want to make the globally search for the specific column in the datatable, so far i was using different tech

for example bSearchable and column().search().draw method and alot more

but i am succeeded yet...
here,s my code

$('#index_table input[type=search]').on( 'keyup click', function () {
// table1.column(1)
// .search("^" + this.value, true, false, true)
// .draw();
// });

'aoColumnDefs': [
{ 'bSearchable': true, 'aTargets': [ 0 ] }
]

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @asifjee104 ,

    I'm not clear what you're after, but hopefully this example here will help.

    Cheers,

    Colin

  • kthorngrenkthorngren Posts: 21,670Questions: 26Answers: 5,017

    This won't work because all columns are searchable by default so it doesn't disable the others:

    'aoColumnDefs': [
    { 'bSearchable': true, 'aTargets': [ 0 ] }
    ]
    

    Don't think this will invoke an event on the default global search:

    ```
    $('#index_table input[type=search]').on( 'keyup click', function () {
    ``

    If you want to take over the global search input you would want to do something like this example then do the column based search:
    http://live.datatables.net/jorexujo/1/edit

    An alternative is to set all of the desired columns to searchable: false using a class. In columnDefs.targets you can specify a class. See this example to turn off searching in all columns except the first:
    http://live.datatables.net/jefaqilo/1/edit

    Kevin

This discussion has been closed.