jQWidgets Forums

jQuery UI Widgets Forums Grid Porgramatically setting Filter

This topic contains 2 replies, has 2 voices, and was last updated by  George S 9 years, 5 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • Porgramatically setting Filter #79405

    George S
    Participant

    I have a button, which is supposed to create and enable a filter. When I run it, everythign appears to run, the column turns blue, but no data is filtered, and when I look at the filter drop down, it does NOT have the values in it (unlike your example I am at a loss as to why.

    Here is my code.

    
        var myGrid =  $("#productListDetail");
         // Clear any existing filters
        
        myGrid.jqxGrid('clearFilters'); 
        
        // Create a NEW FILTER object
        
        var filtergroup = new $.jqx.filter();
        var filtercondition = 'contains';    
        var filtervalue = 'DATABASE';
    
          // create and add the filter.
          var filter1 = filtergroup.createfilter('stringfilter', filtervalue, filtercondition);    
          myGrid.jqxGrid('addfilter', 'PROD_TIER4_DESC_FPH', filtergroup);
         // apply the filters.
         myGrid.jqxGrid('applyfilters');
    

    Any help appreciated.

    As a followup question, does this syntax/functionality work if Filtermode = Excel? I am NOT using that, but would like to at some point…

    Porgramatically setting Filter #79430

    Dimitar
    Participant

    Hello George S,

    Your code seems correct. Could you, please, share a complete jsEditor/JSFiddle example reproducing the reported behaviour, so that we can test it and determine what causes the issue? Please also share if any errors are thrown in your browser’s console.

    In filtermode: 'excel', filters can be applied programmatically the same way.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    Porgramatically setting Filter #79456

    George S
    Participant

    Solved: I did not have the filtergroup.addfilter statement.

    Bottom portion of code SHOULD be…

    
     // create and add the filter.
          var filter1 = filtergroup.createfilter('stringfilter', filtervalue, filtercondition); 
          filtergroup.addfilter(filter_or_operator, filter1);   
          myGrid.jqxGrid('addfilter', 'PROD_TIER4_DESC_FPH', filtergroup);
         // apply the filters.
         myGrid.jqxGrid('applyfilters');
          
    

    Thank you

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.