jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Filters not working
Tagged: filtering
This topic contains 4 replies, has 2 voices, and was last updated by Peter Stoev 11 years, 1 month ago.
-
AuthorFilters not working Posts
-
I have 2 grids. On changing values in 1 Grid the other one will update. Have written those changes in Cell Value change method. But if i filter the 2nd grid and change the filtered rows in the 1st Grid then the changes are not applied in the 2nd Grid. Can you please suggest how to over come this issue?
i tried doing the below.
when onchange method starts of Grid 1 then
var filterGroups = $(“#jobCodeSummaryGrid”).jqxGrid(‘getfilterinformation’);
var info = “”;
for (var i = 0; i < filterGroups.length; i++) {
var filterGroup = filterGroups[i];
//info += “Filter Column: ” + filterGroup.filtercolumn;
var filters = filterGroup.filter.getfilters();
for (var j = 0; j < filters.length; j++) {
// info += “\nFilter: “;
info += filters[j].value;
// info += “\nCondition: ” + filters[j].condition;
//info += “\nOperator: ” + filters[j].operator;
}
}$(“#jobCodeSummaryGrid”).jqxGrid(‘clearfilters’);
Then do all the calculations / Logics
then
var filtergroup = new $.jqx.filter();
var filter_or_operator = 1;
var filtervalue = info;
var filtercondition = ‘contains’;
var filter1 = filtergroup.createfilter(‘stringfilter’, filtervalue, filtercondition);
filtergroup.addfilter(filter_or_operator, filter1);
$(“#jobCodeSummaryGrid”).jqxGrid(‘addfilter’, ‘strJobCodeId’, filtergroup);But nothing seems to happen.
Hi Akshar,
The following example: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/filtering.htm?arctic demonstrates how to apply a filter through API.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Hello Peter,
I am able to achieve the output. But there is a small problem. once i apply the filters back, in the filters by default all will be selected. But in the grid data will be filtered with the filter i chose before. So the user has to uncheck all and then select the required things. I used the following code to achieve this. Am not getting what am doing wrong..var filterGroups = $(“#jobCodeSummaryGrid”).jqxGrid(‘getfilterinformation’);
var info = “”;
for (var i = 0; i < filterGroups.length; i++) {
var filterGroup = filterGroups[i];
//info += “Filter Column: ” + filterGroup.filtercolumn;
var filters = filterGroup.filter.getfilters();
for (var j = 0; j < filters.length; j++) {
// info += “\nFilter: “;
info += filters[j].value;
// info += “\nCondition: ” + filters[j].condition;
//info += “\nOperator: ” + filters[j].operator;
}
}$(“#jobCodeSummaryGrid”).jqxGrid(‘clearfilters’);
DO THE LOGIC
var filtergroup = new $.jqx.filter();
var filter_or_operator = 1;
var filtervalue = info;
var filtercondition = ‘contains’;
var filter1 = filtergroup.createfilter(‘stringfilter’, filtervalue, filtercondition);
filtergroup.addfilter(filter_or_operator, filter1);
$(“#jobCodeSummaryGrid”).jqxGrid(‘addfilter’, ‘strJobCodeId’, filtergroup);
$(“#jobCodeSummaryGrid”).jqxGrid(‘applyfilters’);Hi Akshar AK,
By all will be checked, I suppose that you use Checked List Filter and Filter Row. If that is so, the Checked List Item states would not take into account a filter applied through the API and would be displayed as Checked. That’s the behavior at least in ver. 2.8 which you previously wrote that you use.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.