Using links instead of dropdown for length filter

Using links instead of dropdown for length filter

VasyaVasya Posts: 2Questions: 0Answers: 0
edited July 2012 in General
Is there are any way to replace standard drop down with something like "10 | 25 | 50 | All" links?

Replies

  • VasyaVasya Posts: 2Questions: 0Answers: 0
    After looking at the donations page I realized how this can be done.
    I've used
    [code]
    "sDom": 'f<"clear"><"table-keys-top">rtp<"clear">'
    [/code]
    with
    [code]
    $('div.table-keys-top').html('Showing 10 | 25 | 50 | all');
    $("div.table-keys-top span").click( function () {
    if ( this.innerHTML == "10" ) {
    oTable.fnSettings()._iDisplayLength = 10;
    oTable.fnDraw();
    } else if ( this.innerHTML == "25" ) {
    oTable.fnSettings()._iDisplayLength = 25;
    oTable.fnDraw();
    } else if ( this.innerHTML == "50" ) {
    oTable.fnSettings()._iDisplayLength = 50;
    oTable.fnDraw();
    } else {
    oTable.fnSettings()._iDisplayLength = -1;
    oTable.fnDraw();
    }
    });

    [/code]
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    Very nice :-).

    Just one comment - it would be worth using the fnLengthChange plug-in rather than setting the "private" variables directly: http://datatables.net/plug-ins/api#fnLengthChange .

    Allan
This discussion has been closed.