See example below for demonstration.
For more examples and documentation please visit dedicated jQuery DataTables AlphabetSearch page.
See example below for demonstration.
For more examples and documentation please visit dedicated jQuery DataTables AlphabetSearch page.
The latest version 1.1.1 does not work right. If the table does not have the ‘A’ in the dom the table fails to load.
Thanks for your comment. There was a problem with the demo in the article which I forgot to update after 1.1.1 update. Otherwise the plug-in works, see this example
Thank you for this. I’ve been using it for a few days with a client listing table on my company intranet and have just noticed that the letter ‘W’ doesn’t appear in the alphabet filter, even though I have 3 clients starting with ‘W’. Can you help?
Good catch, silly me. It’s fixed in v.1.1.2.
Thank you. I did manage to fix it though by adding this to the initialisation
Is there an easy way of specifying which letter is selected when the page loads instead of showing ALL by default?
You can use
alphabetSearch()
API method, see https://jsfiddle.net/xrkadueu/.Perfect, thank you!
How we can add href tags for listing?
You need to use columns.render option to generate a link for a cell.
How do you have it display without the a grouping, display without the
tr.alphabet_group
?Try applying the following CSS rule:
tr.alphabet_group { display: none; }
Michael,
I enjoy your blog, great job both visually and informational.
I did apply the CSS, but then the row coloring is off, for some of the rows where is gets removed now appear the same color . I did notice that on DataTables.net his sample does not have it. Just wondering where there is documentation on the various values that you can pass. maybe there is some CSS numbering that applies to the tr.alphabet_group?
Thanks
Louis, thanks for the compliments. I put together an example (https://jsfiddle.net/dx5arbnt/17/) and cannot replicate the problem you’re describing. Can you amend this example to demonstrate what you mean?
Thanks, it must be something in by CSS I have to look into it
Michael,
Thanks for your help. The issue was how I was applying the CSS to get the rows to alternate colors by using a pseudo class rather than the using the generated odd even classes DUD!!!
Hey any chance this will work with angularjs?
I could be wrong but I assume if you use angular-datatables, it’s just a matter of including Alphabetical search plug-in and supplying additional options to the configuration object
this.dtOptions
.Hi,
I share my datable code between multiple data source an pages an in some case the Alphabet filtering feature is not needed.
is there a simple way/option to disable completely the plugin while keeping all its source files loaded?
Now if I simply remove the A letter from
dom
DataTable option the error is:It will be useful a simple init option inside
alphabetSearch: {}
Good catch! It looks like a bug in the code. Let me fix it and I will get back to you.
Pier, try version 1.1.3, the problem should be fixed now. Thanks for reporting the issue!
Now works perfectly by simply removing (conditionally) the A Dom option.
less than 20 minutes of reaction time for a free software is definitely what we can really call “software support”.
Please, accept the small donation that I’ve just send to you and keep up the good work.
Thank you again.
Thank you for your donation and kind words!
Some small suggestions:
– you should check if the infoDisplay variable is not empty before adding “:” (this will allow to set the value to an empty string in order to remove completely the label). Another alternative solution could be to remove completely the “:” separator leaving it inside the variable value
– by clicking the “All” option the data are still grouped by letters and choosing the sort column affect only the grouped rows. In some cases could be very useful to have an extra clickable option (like “Off”) with the effect to activate/deactivate on the fly the alphabet input behavior.
Pier, those are excellent suggestions. I will consider adding them in the next update. Regarding #2, I may add API methed to enable/disable the feature since I assume not everyone would want to have On/Off switch for the alphabet search. I could be wrong though.
Regarding #2 you could add an init options (like onOffSwitch: true|false) that will add the link before the infoAll item. Just an idea.
Just added support for #1 making colon completely optional. I will think about #2.
Ok, one last improvements.
The script look for the first char into the cell of the indexed column in order to match the alphabet letter. This is OK for plain text content, but if the cell contains even a simple link that wrap the text (imagine the link to edit that row of data) the picked char is the “<" of the anchor tag and the alphabet filter stop working well (all rows are grouped under the "<" char). I think that it could be better to pick the first "displayed" char of the cell.
That seems like unnecessary complication. jQuery DataTables already have the tools to correct the problem you’re describing. The solution is to use plain-text values in the returned data or table cells and produce HTML markup using
columns.render
option.Hi – any fuerther though on this? I seem to be running into #2 as well…
Patrick, just replied to the related issue on GitHub.
Hi Team,
I created HTML table dynamically using javascript, and then called the function for alphabet search. Sort and searcg works fine, but for the alphabet search (when clicked on the alphabets) I am getting the below error:
Unable to get property ‘Api’ of undefined or null reference
What version of jQuery DataTables do you use? Our plug-in requires 1.10 or higher.
I saved the page and see two versions of jquery.min being saved 1.11.0 and 2.1.3. If can provide the URL of the website if required. Can two versions of jquery be an issue.
Data table min version is 1.10.13
I was asking about jQuery DataTables plug-in version, not jQuery version. But multiple versions of jQuery could potentially cause a problem as well.
Thanks for the reply and sorry for the confusion its 1.10.13
Hi Michael,
Thanks for all the info, it was multiple versions of jquery causing issue, fixed by referring only the latest jquery file.
Hi,
I’m gonna use this table for a mobile app. I want to keep those alphabets in a col ( because of mobile) and table to be responsive like this one http://www.gyrocode.com/articles/jquery-datatables-responsive-and-select-extensions/ .
I’m a new to jquery. can you please tell me if that is possible? and how to achieve this?
I recently used this control, the div containing alphabets renders via jquery file. Instead of changing the jquery, can you explore to achieve this via CSS change. Post page render, alphabet section is a simple div you can alter the DOM later as per your requirements.
This is just a suggestion, as modifying the jquery itself might result in various exceptions.
Thanks for your guidance. I’ll go with changing CSS . Hope i can use responsive table like this one in the link http://www.gyrocode.com/articles/jquery-datatables-responsive-and-select-extensions/ and add alphabetical filter vertically here.
Many thanks.
You are welcome, also this functionality is an extension of DataTables, they do have some responsive functionality implemented, hope it helps refer the link below:
https://datatables.net/extensions/responsive/
I have updated jQuery DataTables AlphabetSearch plugin adding support for small screen devices, please see AlphabetSearch page for more details.
Super Thanks For your work
Currently while clicking on alphabetSearch displaying particular records, onClick of a particular alphabet it should navigate to letter places. Is this possible?
Thanks
Can you please rephrase your question or illustrate it with an example? It is not clear what you’re asking. Thanks!
Hello Michael
Thanks for the demo ,
I have used it in my project and its working
But i have one issue when i use alphabet search with pagination at that time pagination is not working
When i click on all record only that time pagination working
If you have any solutions please help us
It is by design. When you filter the table by a letter, only those records that start with that letter are displayed, therefore there could be only 1 page.
Your script is awesome! We have it pretty much implemented but the letter above each section does not display. Instead we see an angle bracket – https://biblio.csusm.edu/course-reserves. Could you point me in the direction for solving this problem?
Thank you.
Ian, thanks for reporting this issue. Just pushed an update fixing this issue. Please use the latest version of the plugin.
Thank you so much for pushing the update so quickly. We have not yet had a chance to test but will do so soon. We really appreciate your willingness to share this plugin.
Works beautifully! thank you
Hi – working to add this neat functionality to a data tables implementation where the alpha sort applies to column 2. Interestingly, when I click on “All” and then attempt to sort one of the columns, it maintains the starting sort on column 2’s first letter and then will apply a secondary sort on the clicked column… for example:
Studio–Movie–Year
Marvel–Avengers–2012
Marvel–Black Panther–2018
Marvel–Captain America The First Avenger–2011
Marvel–Captain America Civil War–2016
Marvel–Thor Ragnarok–2017
If alphabetSearch is pointed to the movie name and I attempt to reverse sort on year, the only change is to flip the two Captain America lines… Ideally I’d like the alphabetSearch index to follow the current sort, but I cant see how to do this. Thoughts?
Thanks for your comment, just replied you on GitHub.
To implement buttons (PDF, COPY, EXCEL) + the alphabet selection, get 2 search input, do you know how to change it?
I used dom: ‘A’ “iflp > B <" bottom "iflp > ‘,
But but two repeating buttons appear
Hi. just tried to use the script and i am getting a console error: Cannot read property ‘fn’ of undefined
As a result the table is not loading the alphabetical index.
Any ideas
Can you share your page or create an example demonstrating the problem?
Here is the page Michael.
The error triggers on page load which means something might be wrong with the scipt loading along with the other JS scripts:
http://os135.it.auth.gr/new_site/index.php/publishers-list/
The problem is that jQuery was running in no-conflict mode. I just updated the plug-in adding a workaround for this problem. Please use the most recent version (1.2.5 at the moment).
Thank you Michael! You’re great!
Is there any way Michael, to translate certain strings from the plugin, such as “Display” ?
Thank you
Yes, please see Options and Localization example.
Thanks Michael. Sorry for missing that spot.