fnFilter cache results

fnFilter cache results

vsekvsek Posts: 30Questions: 17Answers: 0

Hi all, have a screen where everything works fine. Expect one thing. My fnFilter works just fine when using it from drop down list on the screen. However when I close the screen and reopen it the value is cached to previous selected value. I have the below code occuring to reset it on open but it doesn't ever happen. I verified the "reset" method works by putting and alert in there. But setting the fnFilter to an empty string value doesn't work. Is there something else I need to do?

window.onopen = reset();    
function reset(){               
    $(dataTableId).dataTable().fnFilter("" , 4, true, false, false, false); 
}

This is the code that handles the drop down list that works now
function changeType(){

    var dataTableId = '#standard_datatable';
    var selectedValue = document.getElementById("feedType").value;          
    $(dataTableId).dataTable().fnFilter(selectedValue , 4, true, false, false, false); 
}

This is my data table.
// Data Table
$(dataTableId).cmaDataTable({
sortTableByCol : 2,
ajaxSource : "/cma/contents/load_data",
flagHideColumns : true,
flagShowStatusFlag : false,
arrayOfColumnsToHide : []
});

This is my select list

<

div style="height: 48px" align=right>
File Feed Type:
<select name='feedType' id='feedType' onChange=changeType() style="font-size:11px;">
<option value=""> </option>
<option value="dutyReferenceFeed">Duty Reference</option>
<option value="exportControlClassificationMapFeed">Export Control Classification Map</option>

</select>    

Answers

  • allanallan Posts: 63,192Questions: 1Answers: 10,412 Site admin

    Happy to take a look at a test case showing the issue. Also I'd suggest you use column().search() rather than the legacy fnFilter method as that will be removed in the next major update.

    Allan

  • vsekvsek Posts: 30Questions: 17Answers: 0
    edited October 2019

    ok I changed it to now use the "search" but I am getting exact same results, below is code
    This is triggered by an "onChange" in the drop down list. This works. Problem is it retains this value when I close and reopen the screen.

    function changeType(){
            var dataTableId = '#standard_datatable';
            var selectedValue = document.getElementById("feedType").value;          
            $(dataTableId).DataTable().column(4).search(selectedValue).draw(); 
        }
    

    I experimented with this type of code on on but no luck. Doing all this using chrome if it matters

        window.onOpen = reset();
        
        function reset(){
            var dataTableId = '#standard_datatable';
            $(dataTableId).DataTable().search("").draw(); 
        }
    

    Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Hi @vsek ,

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.