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. Image for the cookie policy date
close icon

Problems Filtering GridGroupingControl

Hi,

I am trying to filter records in a gridgroupingcontrol based on the values in 3 columns. It seems like it should be an easy thing to do but I cannot seem to get correct results.

My grid has a "service code" column with a code for a service type like "0", "1", "2", "A", "B", "C" etc., an "authorised" column that has a string value of either "0" or "1" and a "preferred" column that has a string of either "0" or "1" as well. The user is supposed to be able to select any combination of "service code", "authorised" and "preferred" values and the grid should display only the records that match the selected values.

For example, if I want to show only records where (("service code" = "1") and ("authorised" = "0") and ("preferred" = "1" or "preferred" = "0")) then a simplified version of my code looks like this:

private void filterGrid()
{
ggc.TableDescriptor.RecordFilters.Clear();
ggc.TableDescriptor.RecordFilters.LogicalOperator = FilterLogicalOperator.And;

String servicesFilterString = "([SERVICE_CODE] = '1')";
String authorisedFilterString = "([AUTHORISED] = '0')";
String preferredFilterString = "([PREFERRED] = '1' OR [PREFERRED] = '0')";

RecordFilterDescriptor rfd1 = new RecordFilterDescriptor(servicesFilterString);
ggc.TableDescriptor.RecordFilters.Add(rfd1);

RecordFilterDescriptor rfd2 = new RecordFilterDescriptor(authorisedFilterString);
ggc.TableDescriptor.RecordFilters.Add(rfd2);

RecordFilterDescriptor rfd3 = new RecordFilterDescriptor(preferredFilterString);
ggc.TableDescriptor.RecordFilters.Add(rfd3);

ggc.EndUpdate(true);
ggc.Refresh();
}

For some reason this approach doesn't seem to be working. For example, if I construct the "preferred" filter string as "([PREFERRED] = '1' OR [PREFERRED] = '0')" then the filter works as expected; however, if I construct it in the reverse order "([PREFERRED] = '0' OR [PREFERRED] = '1')" it doesn't filter the grid correctly (for example, all rows are filtered out of the grid when all rows should be displayed). Similarly, the order that of the conditions in the "services" filter string seems to affect whether the grid is filtered correctly and for certain seemingly random values all records in the grid are filtered out inexplicably. I can't see any reason why the order of the conditions should have any effect on the results.

Any help with this problem will be much appreciated!

Thanks!!

3 Replies

TC Tim Cristofoli July 10, 2007 07:18 AM UTC

By the way, I am using Syncfusion version 4.2.0.6.


AD Administrator Syncfusion Team July 10, 2007 08:06 AM UTC

Try removing the TIC marks.

String servicesFilterString = "([SERVICE_CODE] = 1)";
String authorisedFilterString = "([AUTHORISED] = 0)";
String preferredFilterString = "([PREFERRED] = 1 OR [PREFERRED] = 0)";




TC Tim Cristofoli July 14, 2007 04:42 AM UTC

That seems to have fixed it. Thanks for the super quick help!!

Loader.
Live Chat Icon For mobile
Up arrow icon