Hi,
i am using the xamGrid v12.2 for silverlight ... while making use of the in-built filter options using the filter menu, i am not able to get the multiple values that have been selected for that column. the e.FilterValue always shows the last option selected in that column.
Hello san kam,
Thank you for your post!
Your mentioning of e.FilterValue leads me to believe that you are utilizing the XamGrid.Filtering event in your project. This will always reflect the most recently selected value in the filter for that column, as the e.FilterValue is not a collection, but a single value. Instead of using e.FilterValue, I would recommend that you look into the e.RowFiltersCollection. This collection contains RowsFilter objects which represent all of the filters applied to your grid. Each of these RowsFilter objects have a Conditions collection, which contain ComparisonCondition objects. Each of these ComparisonCondition objects has a FilterValue property, which you can check to retrieve your selected filter menu filters. One thing to note is that you will want to place the calls to e.RowFiltersCollection inside of a Dispatcher.BeginInvoke(new Action(() => { your code here...})). The reason for this is because when the XamGrid.Filtering event is called, this collection is populated with a RowsFilter object, but that RowsFilter does not have anything in its Conditions collection yet.
As an alternative to handling the XamGrid.Filtering event, you may also want to consider utilizing the XamGrid.Filtered event. By this time, the RowFiltersCollection will be fully populated, and you can access your RowFiltersCollection from the XamGrid at any time by using myXamGrid.FilteringSettings.RowFiltersCollection.
I have attached a sample project to demonstrate the above. I hope this helps you.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support
Hi Andrew,
Thanks for your reply, i had tried accessing the Conditions collection but it was giving me errors while trying to do so.
And also now, in one of the columns, there are three values to choose from for filtering. So when i choose one value, it shows the condition as Equals that value but when i choose two values, it shows one unselected value with NotEquals operand and not as two values with Equals operand, is there a way i can force it to show me Equals operand ? This scenarios are when i am using the Dispatcher method you mentioned, but the e.Cancel does not work in that mode.
And in the non Dispatcher mode, the e.Cancel is working fine but the Conditions collection is showing empty in the event handler, while i am debugging.
The force of the XamGrid to show the "Equals" operand is possible, but you will need to use the Excel-style filtering in the XamGrid rather than the filter menu. This is accessed by opening the filter menu and clicking on one of the entries of the sub-menu that opens when you click on "Text Filters" for your text columns or "Number Filters" for your numeric columns in the filter menu. Using this, you can explicitly define the operands that you wish to place on the RowsFilter.Conditions collection of the RowsFilter elements that exist in the XamGrid.FilteringSettings.RowFiltersCollection. The actual operands that are placed when filtering by using just the filter menu itself are handled and determined in the source code of the XamGrid.
Regarding the errors you are receiving when trying to access the conditions collection of your RowsFilter objects, the reason that your are seeing the behavior you are is because when the XamGrid.Filtering event fires, the XamGrid.FilteringSettings.RowFiltersCollection has been populated with your RowsFilter objects, but the newest RowsFilter will not yet have its Conditions collection filled. The dispatcher method I had mentioned circumvents this because when you call a Dispatcher.BeginInvoke(new Action(() => { code here }), it delays the code inside of that action until the Filtering event (in this case) is done firing. After a bit more debugging, I noticed that the code for the dispatcher in the Filtering event actually doesn't fire until after the XamGrid.Filtered is done firing as well. Needless to say, after the Filtered event has already fired, the e.Cancel property of the Filtering event won't do much because the Filtering event has essentially already fired.
For your scenario, rather than handling the XamGrid.Filtering event and cancelling it, I would recommend that you handle the XamGrid.Filtered event. In this event, the RowsFilters that exist within the XamGrid.FilteringSettings.RowFiltersCollection will have their Conditions collection filled. This will give you the ability to inspect each of the RowsFilter objects in the RowFiltersCollection and inspect the Conditions applied to each one. If a condition or a RowsFilter is not to your liking, you can simulate the e.Cancel of the XamGrid.Filtering event by removing either the condition from the RowsFilter.Conditions collection or the entire RowsFilter from the XamGrid.FilteringSettings.RowFiltersCollection. The project that I had originally sent you has all of the code you need to inspect the RowsFilters and their corresponding Conditions collections.
I hope this helps. Please let me know if you have any other questions or concerns on this matter.