Code set specific Alphabet div Letter
Code set specific Alphabet div Letter
I have a dataTable that contains rows of names of individuals. Each entry is a link to a another page containing additional information on the selected individual. After viewing the individuals information I want to return to the table page and specifically to the alphabet letter from which I left.
Specifically, if from the table page I selected the Letter M and then an individual's name from the M list, which then takes me to the individuals record, I want to be able to return to the table page Letter M.
Given that the selected letter is the first letter of the individuals last name, I would include a menu item on the individual page that would return to the table page and pass the letter parameter.
I have tried the following code in the initComplete function but it does not work.
$('div.myAlphabet.alphabet span:eq(' + thisLetter + ')').click();
Where thisLetter is previous defined as 'M'
Any help is greatly appreciated.
jdadwilson
Answers
Hi @jdadwilson ,
You could try implementing
stateSave
, see example here.Cheers,
Colin
Colin, thanks for the reply.
I looked at the example you suggested. Added the stateSave line to my code. Didn't work.
I noticed below the example a box identifying what versions of jQuery and dataTables were loaded with the example. I set both of them in my code. Got an error message... "Bootstrap's JavaScript requires jQuery version 1.9.1 or higher, but lower than version 3."
Changed the jQuery version to 2.2.4. Still didn't work.
Maybe I am not understanding what the stateSave really does. Follow this example
I would like the table to reload to the previously Selected letter (M in this case, and even to the selected page number).
If the stateSave will not do this then might it be possible to set the letter and page number via parameters passed to the page via the URL. I tried this...
but, that didn't work either. I just defined thisLetter = 'M' for a test.
Note: I am running version 1.10.11 of dataTables. I tried 1.10.18 but the site blows up. With over 60 tables on the site upgrading to a new version is a major endeavor. One that I may soon have to bite the bullet and do.
Again, thanks for your assistance. Your help is greatly appreciated.
jdadwilson
Hi @jdadwilson ,
It's hard to diagnose without seeing it in action. We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
I implemented the code of this example. It does what I want it to do! BUT, on the first pass through the table load it gets an error on this line...
Here is the complete table code...
Thanks for your help!
jdadwilson
Yep, you're close. The error is because there's no saved state on the first pass through, so the code should check for
state === null
before referencingstate.selected
.Colin
I modified the code as follows...
Works great... no error!
Thanks, for your work help.
jdadwilson