ktm5124
ktm5124

Reputation: 12123

jqGrid - 'in' op not working for filters

I have a simple demo that gets a "greater-than" filter working on a table of test scores. The source can be found by clicking here. If you scroll down to var myfilter, you will see that I have one of the rules commented out.

var myfilter = {
    groupOp: "AND",
    rules: [
        {field: 'score', op: 'gt', data: 70},
        //{field: 'grade', op: 'in', data: [10, 11, 12]}
    ]
};

This rule says to only select rows for grades 10, 11, 12. However, when I uncomment this rule it doesn't work. In fact, it even breaks the table. Is this a bug, or am I going about it wrong?

To be clear, I simply want to find a way to use the op: 'in' feature. The jqGrid wiki on searching lists op: 'in' under the values for sopt, so there should be a way to do it...

Upvotes: 2

Views: 677

Answers (1)

Oleg
Oleg

Reputation: 221997

You are right. The current implementation of local searching don't support "in" operation. It uses just "eq" instead.

So I would suggest you to use block with "eq" operations instead of "in". The example from your question could be rewritten to the following:

var myfilter = {
    groupOp: "AND",
    rules: [
        {field: 'score', op: 'gt', data: 70},
    ],
    groups: [
        {
            groupOp: "OR",
            rules: [
                {field: 'grade', op: 'eq', data: 10}
                {field: 'grade', op: 'eq', data: 11}
                {field: 'grade', op: 'eq', data: 12}
            ]
        }
    ]
};

See description of the full format of filters here.

Upvotes: 2

Related Questions