ParamQuery grid support forum
General Category => Help for ParamQuery Grid (free version) => Topic started by: biswajit on October 18, 2016, 01:05:32 pm
-
I want the result based on filter mode "OR" according to input in autocomplete i.e in autocomplete if I select Owner= X as well a Manager=Y then grid will show all records for which Owner= X plus all records for which Manager = Y. For example, if there are 2 record for Owner=X and 3 records for Manager=Y then grid will show all 5 records.
Now, If I select Document Type=ABC with above autocomplete input then I want the result where Owner=X and Manager=Y and Document Type=ABC (i.e I want result based on filter mode "AND").
For this situation I write the following code-
$( "#grid_documents" ).pqGrid( "option", "filterModel", { on: true, mode : "OR" } );
$("#grid_documents").pqGrid( "filter", {
oper: 'add',
data: [
{ dataIndx: 'Detail', condition: 'range', value: ["X", "Y"]}
]
});
$("#grid_documents").pqGrid( "filter", {
oper: 'add',
data: [
{ dataIndx: 'Owner', condition: 'range', value: ["X", "Y"]}
]
});
$("#grid_documents").pqGrid( "filter", {
oper: 'add',
data: [
{ dataIndx: 'Manager', condition: 'range', value: ["X", "Y"]}
]
});
$( "#grid_documents" ).pqGrid( "option", "filterModel", { on: true, mode : "AND" } );
$("#grid_documents").pqGrid( "filter", {
oper: 'add',
data: [
{ dataIndx: 'DocType', condition: 'regexp', value: "ABC"}
]
});
Here I attached my filter UI, I think it may help to understand the stated problem.
Thank You.
-
First of all, separate filter functions for different columns ( not good performance wise) can be combined into a single call.
$("#grid_documents").pqGrid( "filter", {
oper: 'add',
data: [
{ dataIndx: 'Detail', condition: 'range', value: ["X", "Y"]},
{ dataIndx: 'Owner', condition: 'range', value: ["X", "Y"]},
{ dataIndx: 'Manager', condition: 'range', value: ["X", "Y"]}
]
});
2. Try this for switching the mode.
$( "#grid_documents" ).pqGrid( "option", "filterModel.mode", "AND" );
PS: Your attachment is empty.
-
Sorry, its not working, the result I got, I am explaining bellow -
Case 1: When I am writing the following code-
$( "#grid_documents" ).pqGrid( "option", "filterModel.mode", "OR" );
$("#grid_documents").pqGrid( "filter", {
oper: 'add',
data: [
{ dataIndx: 'Detail', condition: 'range', value: ["Tom Brook_52", "Templeton Robinson"]},
{ dataIndx: 'Owner', condition: 'range', value: ["Tom Brook_52", "Templeton Robinson"]},
{ dataIndx: 'Manager', condition: 'range', value: ["Tom Brook_52", "Templeton Robinson"]}
]
});
I am getting the result shown in picture "case1".
Cae 2: When I am writing
$( "#grid_documents" ).pqGrid( "option", "filterModel.mode", "OR" );
$("#grid_documents").pqGrid( "filter", {
oper: 'add',
data: [
{ dataIndx: 'Detail', condition: 'range', value: ["Tom Brook_52", "Templeton Robinson"]},
{ dataIndx: 'Owner', condition: 'range', value: ["Tom Brook_52", "Templeton Robinson"]},
{ dataIndx: 'Manager', condition: 'range', value: ["Tom Brook_52", "Templeton Robinson"]}
]
});
$( "#grid_documents" ).pqGrid( "option", "filterModel.mode", "AND" );
$("#grid_documents").pqGrid( "filter", {
oper: 'add',
data: [
{ dataIndx: 'DocType', condition: 'regexp', value: "Property Image"}
]
});
I am getting the result shown in picture "case2".
My intended result shown in picture "DocumentFilter"
-
When the mode is switched, it is applied to all the columns.
In your case "AND" is applied to all columns, that is why the recordset is empty.
-
Thank you for your reply.
Is there any way to get my intended result using local filtering?