I have a grid that does not have the filter cell visible. If I configure the filter key, type and filter action then perform a reloaddata() on the gridview the filter cell appears. What I can see how to do is to remove it? My users dont always need to see the filtercell and so I am looking at a way to toggle it on and off.
How can I do this?
Thanks in advance.
Paul
Hi Paul,
When you don't want the filter row to appear, set the DataSourceHelper's FilteringKey property to null.
Then call InvalidateData() on the DataSourceHelper. <- This tells the DataSource that it shouldn't tell the grid to display a filter row
Finally update the grid by calling UpdateData() on it <- This tells the grid to reevaluate the information it got from the DataSource.
dsh.FilteringKey = null;
dsh.InvalidateData();
gridView.UpdateData();
And thats it.
Hope this helps,
-SteveZ
Hey Steve,
I tried your code above and got the same problem as an earlier result. Setting the FilteringKey to null raises an exception. It doesn't like being set to null.
-- Stack Trace:
System.ArgumentNullException: Argument cannot be null.Parameter name: value at Infragistics.IGGridViewDataSourceHelper.set_FilteringKey (System.String value) [0x00000] in <filename unknown>:0 at vEvents.gridfilterpopup.<ViewDidLoad>m__1 (System.Object sender, System.EventArgs e) [0x00048] in /Users/pauldavey/Projects/vEvents/vEvents/gridfilterpopup.cs:45 at MonoTouch.UIKit.UIControlEventProxy.Activated () [0x00000] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIControl.cs:30 at at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr) at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38 at vEvents.Application.Main (System.String[] args) [0x00000] in /Users/pauldavey/Projects/vEvents/vEvents/Main.cs:17
I agree there is definitely a bug somewhere, and i'm going to look into it.
For now though, i found a workaround so that you can continue to move forward on your project:
if(_gridView.FilterRowHeight == 0) { _gridView.FilterRowHeight = 50; } else { IGGridViewFilterCell cell = _gridView.ResolveCellForPath(IGCellPath.CreateCellPath(IGGridViewConstants.kFilterRowIndex, IGGridViewConstants.kFilterRowIndex, -1)) as IGGridViewFilterCell; cell.TextField.BecomeFirstResponder(); if(cell != null) cell.TextField.Text = ""; _gridView.BecomeFirstResponder(); _gridView.FilterRowHeight = 0; } _gridView.UpdateData();
Essentially we're just tricking it into thinking the textField got focus setting a new value and removing focus away from it.
I cant get your workaround to work. I'll have to drop the toggling for the moment. It would be get to get this fixed though and a 'how to' posted. Any ideas on the process involved in that and what sort of time scales it might take?
Thanks,
So i've written up a bug for you. I've already made fixes, which include better support for the empty string of the filtering key, and also the ability to more easily clear and set a filters for both the objective-c and monotouch versions of the control.
So once you get the fix, you'll be able to do the following:
if(_ds.FilteringKey == "") { _ds.FilteringKey = "firstName"; _gridView.UpdateData(); } else { _ds.FilteringKey = ""; _ds.ClearFilter(_gridView); }
The ClearFilter method is new and will remove any filter currently applied and will also clear out the FilterCell's value.
I believe the next SR isn't scheduled for a couple of weeks, however, if you like you can request a private untested build with these changes.
Hi Steve,
Thats great news thanks! Im happy to wait for the rolled build with the fixes in for the moment. I am presuming that they will be rolled in to the 13.1 version? When is this being released, do you know?
13.1 is scheduled to be released sometime this week. So it was too late to include the fixes in the release version. However, it will be in the first Service Release of 13.1 which should be getting released in a couple of weeks.
If that is too long for you to wait, let us know and we can get you an untested build with the fixes earlier.