Search is a core feature of DataTables - in fact it was the first feature that was implemented in the code, way back in 2007 as it was key to what DataTables was designed to do: let users find information in complex data sets quickly and easily. DataTables' search options have come along way since that initial work and provide a range of options through the
search()DT method and among others.
Often, however, you will wish to customise the search options of DataTables to match your own needs. This might be as simple as providing a custom input that fits in perfectly with your site's general UX, or you might want to use a complex search algorithm.
To meet this need, DataTables provides a custom search API which can be used to perform whatever search logic you wish. In this three part series of posts I will introduce this API, showing how to use it and provide custom search functions that match your specific needs. As a working example an alphabet search bar will be developed as part of this series showing you how various aspects of the DataTables plug-in system work.
- Part I (this post): Introducing customer search and showing a clickable alphabet filter
- Part II: Add user information showing the number of search results for each option in the filter
- Part III: Creating a feature plug-in for DataTables incorporating the previously developed code for reuse flexibility.
This post is a little bit off the beaten path for the DataTables blog. Rather than discussing DataTables or its extensions, here I will present one of the tools that SpryMedia uses to help conduct its day to day business for invoicing, conforming to UK tax rules: a web API for VAT exchange rates.
In future I'll be publishing others APIs that I use to run the business (specifically a version and release notes API) and thoughts on setting up and running a business, but this post will only really be of interest to those of you are are running a business in the UK, are VAT registered and invoice in a currency that is not Sterling. If that is you, this API might make life a little bit easier, if not, then you probably won't be too interested in this article!
Editor provides built in support for the three basic buttons needed in an editable DataTable: Create, Edit and Delete. One further action that is particularly useful is the ability to create a new record using the values from an existing row in the table as the default values - i.e. a duplicate button. This can facilitate fast data entry when working with data that has common information; for example entering information from a monthly invoice into a payments database or tracking a team's score through season.
Although there isn't a built in duplicate button type in Editor, this blog post will show how that functionality can be performed very easily with the Editor API, using a TableTools button to provide the user interaction and finally creating a reusable button plug-in for TableTools that can be used in any of your tables with the addition of a single line of code.
The results of the information presented in this post can be see in the duplicate button example on the Editor site.