I need the filter to reset upon selection change

I need the filter to reset upon selection change

DataTablesUserDataTablesUser Posts: 19Questions: 0Answers: 0
edited February 2012 in DataTables 1.8
I have a select drop down box with data corresponding to each option. When I change from one option to another, it retains the info that I typed into the search. I want the info to be cleared when I switch to another option from the select input. I made a function that clears the value of the text input and makes it so that value=""...but this doesnt clear it. I binded the text box to click, mouseenter and mouseleave as well as the original keyup...So when I switch to another option, It clears when I click the search input or just put the mouse over it...but I need it to be cleared on option change.

Also, I want a submit button next to the search input field so that the filtered data doesnt show up until the user presses the submit button.

Any ideas?

Replies

  • DataTablesUserDataTablesUser Posts: 19Questions: 0Answers: 0
    This code seems to be working so far for clearing the input text after option is changed:

    $('.dataTables_filter input').val('').keyup();

    But now I need to figure out a way to only show the data once an exact match is found...right now I have it searching zip codes, and as you type the digits it shows everything that includes those digits...but I want it to only display the results at 5 digits, and only the result that is an exact match at that point...anything less than 5 digits I want the table to dissapear
  • DataTablesUserDataTablesUser Posts: 19Questions: 0Answers: 0
    ok i got the minimum input of 5 all set, i just need it so that this "if" statement does the opposite:

    right now its displaying the full data set when the input has less than 5 digits, i need it to display an empty data set


    i tried putting "_fnClearTable();" in there...but it says that aoData is null or not an object....i'm assuming that's because its not defined yet but im not sure...




    * If the input is blank - we want the full data set
    */
    if ( sInput.length <5 )
    {


    oSettings.aiDisplay.splice( 0, oSettings.aiDisplay.length);
    oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();

    }
  • DataTablesUserDataTablesUser Posts: 19Questions: 0Answers: 0
    nevermind i figured it all out...but how can i retrieve one data element from the data array? it looks like its called aaData...i need to pull a certain piece of data from inside of the array, it's the 2nd one in there
  • DataTablesUserDataTablesUser Posts: 19Questions: 0Answers: 0
    ok its not working again...i need the filter to reset as i change a selection drop down option...its keeping the data in from the previous search...how do i make it reset on change?
  • DataTablesUserDataTablesUser Posts: 19Questions: 0Answers: 0
    got it working
This discussion has been closed.