Combo modification
Combo modification
Hello community, before all, I'm from Argentina, if my english is not good, that could be a good excuse.
As you might know, the datatable plugin has an small combo, usually located on the top left cornor of the table itself. That combo has numbers to make the list longer or smaller according to the needs. What I would like to know is, is there any way to change those numbers to show more or less rows from the beggining? For example I would like to show the numbers (and therefore the rows should change also) by 50, like 50 - 100 - 150 - 200.
Hoping to hear from you.
Rulo
As you might know, the datatable plugin has an small combo, usually located on the top left cornor of the table itself. That combo has numbers to make the list longer or smaller according to the needs. What I would like to know is, is there any way to change those numbers to show more or less rows from the beggining? For example I would like to show the numbers (and therefore the rows should change also) by 50, like 50 - 100 - 150 - 200.
Hoping to hear from you.
Rulo
This discussion has been closed.
Replies
what you mean is the pagination length dropdown. The values are hardcoded, but you can still decide not to use it at all and write a custom one.
Look at this example:
http://datatables.net/examples/basic_init/language.html
_MENU_ is replaced by the dropdown you're currently seeing. This occours around line 3084, btw. Just remove that _MENU_ from the variable in oLanguage and put your custom list in there.
[code]
"sLengthMenu": '\
50\
100',
[/code]
Of course you have to replace %TableID% by the id you assigned to your table in markup.
You might also find the documentation useful as it covers this: http://datatables.net/usage/i18n#oLanguage.sLengthMenu
Regards,
Allan
@Jens: Correct me if im wrong but what you just gave me would change all the datatable's length dropdown, wouldn't it?
@Allan: Thx for that link, it really helped me a lot. I found it a bit funny (not the LOL funny) how it works. On the first load I have the dropdown loaded with the correct numbers, but the table is not loaded with the right number of lines. To make a very ugly example, If i set my first register with 1 I will see 10 lines. Any idea about this?
Yes - you need to set iDisplayLength as well to let it select which one of the options you want to use initially: http://datatables.net/usage/options#iDisplayLength
Regards,
Allan
Rulo