Pagination custom styles
Pagination custom styles
jasonsf
Posts: 6Questions: 0Answers: 0
In version 1.7.6, I had to change lines 574, 575, 585 and 586 to get the custom styles for sPageFirst, sPagePrevious, sPageNext, and sPageLast to function correctly.
FROM
[code]
anStatic[0].className += " "+oClasses.sPageButton;
anStatic[1].className += " "+oClasses.sPageButton;
.
.
.
anStatic[2].className += " "+oClasses.sPageButton;
anStatic[3].className += " "+oClasses.sPageButton;
[/code]
TO
[code]
anStatic[0].className += " "+oClasses.sPageFirst;
anStatic[1].className += " "+oClasses.sPagePrevious;
.
.
.
anStatic[2].className += " "+oClasses.sPageNext;
anStatic[3].className += " "+oClasses.sPageLast;
[/code]
Is this a known issue?
FROM
[code]
anStatic[0].className += " "+oClasses.sPageButton;
anStatic[1].className += " "+oClasses.sPageButton;
.
.
.
anStatic[2].className += " "+oClasses.sPageButton;
anStatic[3].className += " "+oClasses.sPageButton;
[/code]
TO
[code]
anStatic[0].className += " "+oClasses.sPageFirst;
anStatic[1].className += " "+oClasses.sPagePrevious;
.
.
.
anStatic[2].className += " "+oClasses.sPageNext;
anStatic[3].className += " "+oClasses.sPageLast;
[/code]
Is this a known issue?
This discussion has been closed.
Replies
Allan
Thanks,
Jason
Allan
[code]
var oTable;
$(document).ready(function () {
$.fn.dataTableExt.oPagination.iFullNumbersShowPages = 5
$.fn.dataTableExt.oStdClasses.sPageFirst = "A B C";
$.fn.dataTableExt.oStdClasses.sPageLast = "A B C";
$.fn.dataTableExt.oStdClasses.sPageButton = "A B C";
$.fn.dataTableExt.oStdClasses.sPageButtonActive = "A B X";
$.fn.dataTableExt.oStdClasses.sPageButtonStaticDisabled = "Z";
$.fn.dataTableExt.oStdClasses.sPagePrevious = "Z";
$.fn.dataTableExt.oStdClasses.sPageNext = "Z";
oTable = $("#<%= tblPINs.ClientID %>").dataTable({
"sPaginationType": "full_numbers",
"bSortClasses": false,
"bFilter": true,
"sDom": 'r<"search">tlp',
"aaSorting": [[1, 'asc']]
});
[/code]
Here is the rendered HTML. Notice that the "Z" class does not appear in the Previous or Next class list.
[code]
First
Previous
1
2
3
4
5
Next
Last
[/code]
I did notice, however, if I use a single class for each override, it works properly. Perhaps this is a bug in how Datatables handles multiple classes in one class declaration?
Looking at the example, when I use DataTables 1.8 beta 4 on the first page, looking at just the 'First' button when I load the page I have classes of "C" and "Z" applied. "A" and "B" are not applied because the button is not active and therefore the sPageButtonActive definition cases them to be removed. If sPageButtonActive did not contain A and B then they would still be there. Likewise Z is added since the button is disabled and sPageButtonStaticDisabled.
If I then page to the second page the 'First' button has classes of A, B and C. This just sPageFirst. What I'm wondering is if the confusion is around the sPageButtonActive option. Classes in sPageButtonActive are removed from the static buttons, but it is not then added back on if the button is active...
Hmmm - escuse the meandering message please :-). I've just tried this is:
[code]
$(document.body).addClass('a a a');
document.body.className // "a a a"
$(document.body).removeClass('a');
document.body.className // "a a"
[/code]
That is not what I expected and explains at least some of the behaviour of DataTables here. jQuery is only removing the first instance of the class that it finds, but will happily add multiple classes the same. This explains why with your setup if you click next then previous then the 'First' button does not return to it's original state. So this sounds like a little jQuery bug (tried in both 1.6.1 and 1.5.2).
That however doesn't detract from the slightly odd naming scheme I've picked for the DataTables buttons. Something that I'll most certainly tidy up in the next major revision - probably not right now as I'm worried about breaking backwards compatibility though. I think with the jQuery issue known and the DataTables naming being understood (for what it is) then hopefully it is possible to code around this...
Allan
Allan
My "Z" class above is defined as "display:none;" and simply hides those buttons. My goal is to hide the Previous and Next buttons when the screen width is small to avoid wrapping. They are redundant when you have more than iFullNumbersShowPages = 3 or greater, anyway. Having "Z" not applied caused the buttons to remain instead of being hidden.
Knowing about the jquery bug will help. Thanks again.
Jason