jQWidgets Forums

jQuery UI Widgets Forums Grid Cant get my filter to work.

This topic contains 6 replies, has 2 voices, and was last updated by  Programmerswe 9 years, 9 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • Cant get my filter to work. #74859

    Programmerswe
    Participant

    Hi!

    I’m getting the values from my grid by using a web service. And I’m trying to remove some unwanted results from the grid by using the filter function.
    This is how it looks right now:

    var addfilter = function(){
    var fnameFilterGroup = new $.jqx.filter();
    var filtervalue = “test”;
    var filtercondition = “contains”;
    var filter1 = filtergroup.createfilter(‘stringfilter’, filtervalue, filtercondition);

    filtergroup.addfilter(filter1);

    $(“#jqxgrid”).jqxGrid(‘addfilter’, ‘Type’, filtergroup);
    $(“#jqxgrid”).jqxGrid(‘applyfilters’);
    }

    So, I’m basically want to remove all cells that contains “test” from the column named “Type”.
    Shouldn’t this work?

    Cant get my filter to work. #74861

    Vladimir
    Participant

    Hello Programmerswe,

    What filter does is that it returns the results that match the conditions of the filter.
    So if you want to remove results containing “test” you need to use:

    var filtercondition = "does_not_contain";

    You can find all possible filtering conditions in the API Reference for the addfilter function.

    Best Regards,
    Vladimir

    jQWidgets Team
    http://www.jqwidgets.com

    Cant get my filter to work. #74870

    Programmerswe
    Participant

    I’ve tried to change it. Didn’t work.
    Ive got the grid:

    Username | Name | Type
    xxx xxxx test

    I want to remove all rows that contains the type “test” from the grid.
    If that makes the picture of what I’m trying to do clearer.

    Cant get my filter to work. #74876

    Vladimir
    Participant

    Hi Programmerswe,

    Here is an example of how it works:
    https://www.jseditor.io/?key=jqxgrid-filter-example

    As you can see the users with type = ‘test’ get properly filtered.

    Best Regards,
    Vladimir

    jQWidgets Team
    http://www.jqwidgets.com

    Cant get my filter to work. #74877

    Programmerswe
    Participant

    Yeah, I’ve gotten it to work!
    However, is there a possibility to “lock” the specific column search / filter? So the user can’t change the filter content.

    Cant get my filter to work. #74878

    Vladimir
    Participant

    Yes it is possible.

    If you don’t want your users to apply filters to your grid at all you can remove the filterable: true parameter from your grid (or set it to false),
    or if you want to lock only that specific row, you can specify filterable: false for that specific row.
    I have updated the fiddle.

    Best Regards,
    Vladimir

    jQWidgets Team
    http://www.jqwidgets.com

    Cant get my filter to work. #74879

    Programmerswe
    Participant

    Awesome, thank you Vladimir!

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

You must be logged in to reply to this topic.