filter multiple id's in javascript

Questionsfilter multiple id's in javascript
Glenn asked 8 years ago

Hi Abu,

I can filter a single id. Is it possible to filter an array of id's.
eg. array("10016","12345","22222")

The below works for single id.
var myfilter = { groupOp: "AND", rules: []};
myfilter.rules.push({field: "id", op: "cn", data: "10016"});
var myGrid = $("#list_master").jqGrid();
myGrid[0] = myfilter.rules.length>0;
myGrid.setSelection("10016, true);

if I add another element it does not work
myfilter.rules.push({field: "id", op: "cn", data: "22222"});


2 Answers
Abu Ghufran answered 8 years ago

You can use 'in' operator and comma sep vales.
myfilter.rules.push({field: "id", op: "in", data: "10016,12345,22222"});

Glenn answered 8 years ago

Thanks Abu,

That worked perfectly.
Your the best.


Your Answer

6 + 14 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.

How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?