Hello,
Within our grid, we are attempting to create a simple clear filter function. We've gotten the ability to reset our filter with the following line of code:
$(
"#grid"
).igGridFiltering("filter',[]);
Dear Patrick,
Thank you for contacting Infragistics!
We received your support request concerning Clearing filter and filter text in igGrid, and this case has been assigned to me. Infragistics is dedicated to helping you solve this issue.
I am looking into this issue and will get back to you by the end of the day Thursday with more information or questions for you.
Hello Patrick,
It seems that the "updateUI" parameter is not taken into account when empty array is used in order to reset the filter
http://help.infragistics.com/jQuery/2012.1/ui.iggridfiltering#methods
An development issue will be submitted regarding this.
As a temporary workaround you can use the following code snippet
function clearFilter() { var $gridFiltering = $("#grid1").data("igGridFiltering"); $gridFiltering.filter([],true); var editors = $gridFiltering._editors; for (var i = 0; i < editors.length; i++) { editors[i].value(null); } // $("#grid1").igGridFiltering("filter", ([{ fieldName: "ProductID", expr: '', cond: "equals"}])); // $("#grid1").igGridFiltering("filter", ([{ fieldName: "Color", expr: '', cond: "contains"}])); }
var $gridFiltering = $("#grid1").data("igGridFiltering");
$gridFiltering.filter([],true);
var editors = $gridFiltering._editors;
for (var i = 0; i < editors.length; i++) {
editors[i].value(null);
}
// $("#grid1").igGridFiltering("filter", ([{ fieldName: "ProductID", expr: '', cond: "equals"}]));
// $("#grid1").igGridFiltering("filter", ([{ fieldName: "Color", expr: '', cond: "contains"}]));
Thanks, Tsvetelina! That snippet worked exactly as expected.
Out of curiosity, is it possible to set the editor's values/text and programmatically invoking a filter event via filling in the igGridFiltering input?
For example, could I do something like:
editors[i].value("5"); //Assuming i is equal to a ProductID column
editors[i].text("5");
Would this execute a filter event?
Using this approach you wil change only the value of the filtering editor but this won't invoke the filtering event.
You need to use the filter method for the purpose.
function clearFilter() { var colSettings = $("#grid1").igGridFiltering("option", "columnSettings"); for (var i = 0; i < colSettings.length; i++) { $("#grid1").igGridFiltering("filter", ([{ fieldName: colSettings[i].columnKey, expr: '5', cond: colSettings[i].condition}])); } }
var colSettings = $("#grid1").igGridFiltering("option", "columnSettings");
for (var i = 0; i < colSettings.length; i++) {
$("#grid1").igGridFiltering("filter",
([{ fieldName: colSettings[i].columnKey, expr: '5', cond: colSettings[i].condition}]));
I have linked you case to the Development issue 124163. You will be notified once the service release is out include this fix.
Please let me know if I can provide any further assistance regarding this matter.