This is a migrated thread and some comments may be shown as answers.

Column Filtering

2 Answers 117 Views
GridView
This is a migrated thread and some comments may be shown as answers.
John Giblin
Top achievements
Rank 1
John Giblin asked on 15 Mar 2011, 10:16 PM


I have 3 radio buttons that will do the following
1) rbAll: Get all the values
2) rbMapped: Get all the values where the program column is not blank
3) rbUnMapped: Get all the values where the program column is blank
I have all the button clicks go to the below method
I am getting a blank results for all them.  Any ideas

Telerik.Windows.Controls.GridView.FieldFilterDescriptor columnDescriptor = new Telerik.Windows.Controls.GridView.FieldFilterDescriptor("Program", typeof(System.String));
 
if (rbAll.IsChecked.Value)
{
    columnDescriptor.Filter1.Operator = Telerik.Windows.Data.FilterOperator.IsGreaterThan;
    columnDescriptor.Filter1.Value = "0";
    return;
}
if (rbMapped.IsChecked.Value)
{
    columnDescriptor.Filter1.Operator = Telerik.Windows.Data.FilterOperator.IsNotEqualTo;
    columnDescriptor.Filter1.Value = "";
}
else if (rbUnmapped.IsChecked.Value)
{
    columnDescriptor.Filter1.Operator = Telerik.Windows.Data.FilterOperator.IsEqualTo;
    columnDescriptor.Filter1.Value = "";
}
rgvSellingTitles.FilterDescriptors.Add(columnDescriptor);

2 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 16 Mar 2011, 10:15 AM
Hi John Giblin,

Don't use a FieldFilterDescriptor for that purpose. The FieldFilterDescriptor is one of the child descriptors of a ColumnFilterDescriptor used to pre-filter RadGridView and is not supposed to be instantiated by you directly.

You should use a plain simple FilterDescriptor, i.e:

var fd = new FilterDescriptor("Program", FilterOperator.IsEqualTo, string.Empty);

Then make sure you add it to the FilterDescriptors collection of the grid to get the filtering performed, because I have noticed that in one of the if's you have a return statement and this will return before actually adding the descriptor to the grid.

Alternatively, you can go all the way and prepare a brand new custom filtering control that will have these radio buttons and will do the filtering. 

I hope this helps.

Best wishes,

Ross
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
John Giblin
Top achievements
Rank 1
answered on 16 Mar 2011, 02:17 PM
thanks.  That  worked.  I had to tweak it a little since a null value in Oracle came back as a DBNull. I just had to replace the string.Empty with null

I used the following method for all the radio buttons
void MappingClicked()
 {
       
     foreach (Telerik.Windows.Data.FilterDescriptor filter in rgvSellingTitles.FilterDescriptors)
     {
         if (filter.Member == "Program")
         {
             rgvSellingTitles.FilterDescriptors.Remove(filter);
             break;
         }
     }
     if (rbAll.IsChecked.Value)
     {
         //nothing it is removed from above
     }
     if (rbMapped.IsChecked.Value)
     {
         var fd = new Telerik.Windows.Data.FilterDescriptor("Program", Telerik.Windows.Data.FilterOperator.IsNotEqualTo, null);
         rgvSellingTitles.FilterDescriptors.Add(fd);
     }
     else if (rbUnmapped.IsChecked.Value)
     {
         var fd = new Telerik.Windows.Data.FilterDescriptor("Program", Telerik.Windows.Data.FilterOperator.IsEqualTo, null);
         rgvSellingTitles.FilterDescriptors.Add(fd);
     }
 }

Tags
GridView
Asked by
John Giblin
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
John Giblin
Top achievements
Rank 1
Share this question
or