We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Given a DataTable source, show only filter results

Thread ID:

Created:

Updated:

Platform:

Replies:

11725 Mar 15,2004 12:48 AM UTC Apr 14,2004 08:45 PM UTC Windows Forms 9
loading
Tags: Grouping
David
Asked On March 15, 2004 12:48 AM UTC

Given a DataTable as the DataSource, how can I tell the GridGroupingControl to only show rows where "[Level] LIKE ''Verbose''"? Is there a way to apply such a filter to the DataTable and/or the GridGroupingControl? Thanks!

Administrator [Syncfusion]
Replied On March 15, 2004 06:41 AM UTC

You add a RecordFilterDescriptor to the TableDescriptor''s RecordFilters collection. //filter states that start with N RecordFilterDescriptor filter = new RecordFilterDescriptor("state_N"); filter.Expression = "[State] LIKE ''N*''"; this.gridGroupingControl1.TableDescriptor.RecordFilters.Add(filter); Here is a sample.

David
Replied On March 15, 2004 09:58 PM UTC

Okay. Given this, is there a way to filter out a particular set, as in "[State] Not ''''NY''''"? Thanks!

Administrator [Syncfusion]
Replied On March 16, 2004 09:42 AM UTC

Currently, there is no NOT operator. But logical expressions return truth values of 1 or 0. So, if you want any state that does not begin with ''N'', then you can use something like: filter.Expression = "([State] LIKE ''N*'') = 0"; Or, equivalently, filter.Expression = "1 - ([State] LIKE ''N*'')";

David
Replied On April 5, 2004 02:10 AM UTC

After applying a filter, I have tried to remove it, but the grid does not reset. How should I modify the grid to reset. The following is my code: if(!this.verboseOff) { RecordFilterDescriptor filter = new RecordFilterDescriptor("Verbose"); filter.Expression = "([Level] Like ''Error'') = 0"; this.gridGroupingControl1.TableDescriptor.RecordFilters.Add(filter); this.verboseOff = true; } else { this.gridGroupingControl1.TableDescriptor.RecordFilters.Remove("Verbose"); this.verboseOff = false; this.gridGroupingControl1.Update(); }

Administrator [Syncfusion]
Replied On April 5, 2004 10:32 AM UTC

That''s odd. Your code looks correct and should correctly reset the records. I also checked with our GroupCustomers sample and modified it to check if there is a problem in our code base with handling the code snippets you posted but it worked fine. If for some reason you need to manually reset the grid you can set groupingGrid.Table.TableDirty = true and then call groupingGrid.Refresh() Stefan >After applying a filter, I have tried to remove it, but the grid does not reset. How should I modify the grid to reset. The following is my code: > > if(!this.verboseOff) > { > RecordFilterDescriptor filter = new RecordFilterDescriptor("Verbose"); > filter.Expression = "([Level] Like ''Error'') = 0"; > this.gridGroupingControl1.TableDescriptor.RecordFilters.Add(filter); > this.verboseOff = true; > } > > else { > this.gridGroupingControl1.TableDescriptor.RecordFilters.Remove("Verbose"); > this.verboseOff = false; > this.gridGroupingControl1.Update(); > }

David
Replied On April 12, 2004 07:46 PM UTC

Can you provide me with an example using the GroupingGridControl bound to a DataTable, where you can enable and disable a filter for which results to show? I may have some trivial code wrong and a working example would help tremendously. Thanks, David

Administrator [Syncfusion]
Replied On April 13, 2004 09:50 AM UTC

There does appear to be a problem here with the Filter collection. It looks like the collection is using the expression as the look up value instead of the name. So, when you try to find the filter using the name, it cannot. So, you cannot remove it. So, as a work around until we get this corrected (correction should be in the final release), you can use the expression value as the lookup key. Here is the above sample modified showing things working using the expression as the lookup. GroupingDataSample_4766.zip

David
Replied On April 14, 2004 08:08 PM UTC

Thanks. One more thing... In order to let a client chose how to filter, I need to come up with a list of unique items in a column. I can take the list from either the DataTable or the GridGroupingControl. Do you have any suggestions? Thanks! David >There does appear to be a problem here with the Filter collection. It looks like the collection is using the expression as the look up value instead of the name. So, when you try to find the filter using the name, it cannot. So, you cannot remove it. > >So, as a work around until we get this corrected (correction should be in the final release), you can use the expression value as the lookup key. Here is the above sample modified showing things working using the expression as the lookup. >GroupingDataSample_4766.zip > >

Administrator [Syncfusion]
Replied On April 14, 2004 08:45 PM UTC

I would probably get it from the DataTable. If you have our source, there is a method GridFilterBar.CreateUniqueEntries that does this for our Filterbar.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;