Filter using an Select / Option dropdown

Filter using an Select / Option dropdown

benjashbenjash Posts: 13Questions: 0Answers: 0
edited August 2009 in General
Hi Guys,

This plugin is amazing!

I've been putting together a prototype listing here: http://www.wearehome.com/testape.php

It generates the table from an XML file via PHP at the moment.

I've searched on the forums and there are few articles about it, but not spefically..

I basically want to create Filter using an Select / Option dropdown?

ie .. they can pick between spain, turkey portugal etc....

Any help would be great... im going keep you all posted im trying to replace http://www.wearehome.com/plugplaynew_n/sliderchoosenew.php with a more functional tool .

current ones doesnt work very well. (which i didnt make)

Replies

  • allanallan Posts: 61,653Questions: 1Answers: 10,094 Site admin
    Hi benjash,

    Yup, using a select menu for a filter is most certainly possible - have a look at these posts:

    http://datatables.net/forums/comments.php?DiscussionID=259
    http://datatables.net/forums/comments.php?DiscussionID=460

    which will help you in your quest!

    Regards,
    Allan
  • benjashbenjash Posts: 13Questions: 0Answers: 0
    edited August 2009
    http://www.wearehome.com/testape.php

    ok added a dropdown

    heres the jquery:


    [code]
    $('#mytablex').dataTable( {
    "iDisplayLength": 5,
    "sPaginationType": "full_numbers",
    "aoColumns": [
    /* pic */ null,
    /* Country */ null,
    /* Dev */ null,
    /* Type */ null,
    /* Monthly price */ { "sType": "currency" },
    /* Full price */ { "sType": "currency" }
    ]
    } );

    $('#whatever select').change(function() {
    oTable = $('#mytablex').dataTable();
    oTable.fnFilter( $(this).val() );
    } );
    [/code]


    Problem is it duplicates the elements of the table ie .. next and so. mainly because im initializing the table again i think.
  • benjashbenjash Posts: 13Questions: 0Answers: 0
    [code] oTable = $('#mytablex').dataTable( { [/code]

    fixed
  • benjashbenjash Posts: 13Questions: 0Answers: 0
    edited August 2009
    Added a little bit that filters all if "all" is selected.


    [code]$('#whatever select').change(function() {

    goat = $(this).val();

    if (goat == "All") {

    //alert("All results");
    oTable.fnFilter("");
    oTable.fnDraw();

    } else {

    oTable.fnFilter(goat);
    //alert(goat);

    }

    } ); [/code]
  • benjashbenjash Posts: 13Questions: 0Answers: 0
    Added a slider

    http://www.wearehome.com/testape.php


    Trying to et my head round the price range finder

    http://www.wearehome.com/testrane.php


    Goin to create a slider that gets the price range as a next step!
This discussion has been closed.