Combo modification

Combo modification

rulorulo Posts: 3Questions: 0Answers: 0
edited January 2010 in General
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

Replies

  • Jens GutzeitJens Gutzeit Posts: 22Questions: 0Answers: 0
    Hello rulo,

    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.
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Hi Rulo,

    You might also find the documentation useful as it covers this: http://datatables.net/usage/i18n#oLanguage.sLengthMenu

    Regards,
    Allan
  • rulorulo Posts: 3Questions: 0Answers: 0
    Thx Jen and 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?
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Hi rulo,

    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
  • rulorulo Posts: 3Questions: 0Answers: 0
    @allan: Yup, you are some kind of god, thank you very much.

    Rulo
This discussion has been closed.