replace aLengthMenu with buttons
replace aLengthMenu with buttons
Hello everyone,
I am trying to replace the aLengthMenu drop-down with a couple of buttons that say "More" and "Less" (which would map to, say, 10,25,50,100,all), but I couldn't find a way to do this using the API or a plugin. Is what I'm asking possible without tweaking the core?
Thanks
I am trying to replace the aLengthMenu drop-down with a couple of buttons that say "More" and "Less" (which would map to, say, 10,25,50,100,all), but I couldn't find a way to do this using the API or a plugin. Is what I'm asking possible without tweaking the core?
Thanks
This discussion has been closed.
Replies
http://datatables.net/plug-ins/api#fnPagingInfo
are the two plug-in API methods you'll need to do this :-)
Allan
a) Add the following initialization option:
[code]
"oLanguage" : {
"sLengthMenu" : 'Display Less More records'
}
[/code]
b) Implement the following methods:
[code]
$.fn.dataTableExt.oApi.fnShowMore = function( oSettings ) {
var idx = $.inArray(oTable.fnPagingInfo().iLength, oTable.fnSettings().aLengthMenu);
if (idx != -1 && idx < oTable.fnSettings().aLengthMenu.length-1) {
oTable.fnLengthChange(oTable.fnSettings().aLengthMenu[idx+1]);
}
}
$.fn.dataTableExt.oApi.fnShowLess = function( oSettings ) {
var idx = $.inArray(oTable.fnPagingInfo().iLength, oTable.fnSettings().aLengthMenu);
if (idx != -1 && idx != 0) {
oTable.fnLengthChange(oTable.fnSettings().aLengthMenu[idx-1]);
}
}
[/code]
By the way, there's a typo in http://datatables.net/plug-ins/api#fnPagingInfo: In the example, it calls fnInfo() instead of fnPagingInfo()
Thanks again for your help.
Allan