Using Search feature !

Using Search feature !

hamzamuhamzamu Posts: 3Questions: 0Answers: 0
edited September 2009 in General
Hello ,

First of all thank you for the amazing datatable ,

2nd ,I have a question regarding special use of the datatable , in my application , how i can use datatable search only without listing all the records , but list only the search result ( filtered records ) !

as example : i would like to see a result of all people named "John" when searching the Data !

how i can achieve that ?!

Regards

H

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi hamzamu,

    Did you come across the fnFilter() function in the documentation: http://datatables.net/api#fnFilter ? You can just do something like: oTable.fnFilter( "John" );

    Regards,
    Allan
  • hamzamuhamzamu Posts: 3Questions: 0Answers: 0
    Than you ,
    I just read it , which is really helpful , however , am wondering more about search ,

    as example , i have a table of people , and adding an appointment for one i need to search the record then click on " add appointment " link to add appointment to a specific person ,

    am already using Datatable now to listing the people , however , i don't want the table to be displayed unless i am using the search ( filtering ) !

    BTW : Thanks for the link , am going through the documentation again .

    Best Regards

    H
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi,

    Okay - you don't want anything to display, if there is no filter. Interesting one - I didn't really consider that! You can set an initial search string using the 'oSearch' parameter: http://datatables.net/usage/options#oSearch . But I think if you want to allow the user to input their own search, then you'll need to some custom filtering, i.e. if search.length==0, then return false for all records: http://datatables.net/development/filtering

    Allan
  • hamzamuhamzamu Posts: 3Questions: 0Answers: 0
    Easy , Thank you :D Its Done

    Thank You Allan

    Best Regards
This discussion has been closed.