I have a requirement to add a default filter to the my GridView. Therefore I do this simply using the following code:
FilterDescriptor filterDescriptor = new FilterDescriptor();
filterDescriptor.PropertyName = "DistributionStatus";
filterDescriptor.Value = "Active";
filterDescriptor.Operator = FilterOperator.IsNotEqualTo;
filterDescriptor.IsFilterEditor = true;
This is simply code taken from the documentation and modified.
This applies the restriction that I require, but when I open up the filter on screen as a user, I do not see all the values available in the column, so I am unable to remove this filter... Please see attached file (1.png) for an example.
If however, I add a random filter that does not affect the results (2.png), I now see all my available options (3.png). Can anyone suggest if this is a bug? or maybe a setting I need to update or a forced refresh of some kind?
5 Answers, 1 is accepted
Thank you for writing.
I would like to note that the basic filtering and the filtering have a difference in their filtering logic. Hence, the applied filter are different. The Excel-Like filtering is designed to perform cascade filtering via the UI and it uses CompositeFilterDescriotors. In order to achieve your requirement, you must apply the following filter:
FilterDescriptor filterDescriptor =
new
FilterDescriptor();
filterDescriptor.PropertyName =
"Title"
;
filterDescriptor.Value =
"Sales Representative"
;
filterDescriptor.Operator = FilterOperator.IsNotEqualTo;
CompositeFilterDescriptor cfd =
new
CompositeFilterDescriptor();
cfd.LogicalOperator = FilterLogicalOperator.And;
cfd.FilterDescriptors.Add(filterDescriptor);
cfd.IsFilterEditor =
true
;
this
.radGridView1.FilterDescriptors.Add(cfd);
I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Telerik by Progress
Hi Dess,
Thanks for the reply, but unfortunately, this still causes the same issue. Here is my code verbatim:
FilterDescriptor filterDescriptorRemoved = new FilterDescriptor();
filterDescriptorRemoved.PropertyName = "DistributionStatus";
filterDescriptorRemoved.Value = "Removed";
filterDescriptorRemoved.Operator = FilterOperator.IsNotEqualTo;
CompositeFilterDescriptor cfd = new CompositeFilterDescriptor();
cfd.LogicalOperator = FilterLogicalOperator.And;
cfd.FilterDescriptors.Add(filterDescriptorRemoved);
cfd.IsFilterEditor = true;
radGrdVwBookings.FilterDescriptors.Add(cfd);
It seems this creates a custom filter, which removes the valid selections from the list. In this case I only see the 'Active' value which is checked... I would expect to see:
Active - Checked
Removed - Not Checked
Instead I just see
Active - Checked (See 4.png)
Therefore have no option to include the 'Removed' rows.
I have found that the Clear Filter option (see arrow on 4.png) resets the values and the 'Removed' value then appears... it is a work around, but suspect users will be confused by this and at a glance simply assume there are no 'Removed' entries in the grid.
Is there any other way of creating filters so all valid values appear, but only certain ones are checked?
Thanks
Thank you for writing back.
I have missed to include in the code snippet from my previous post a very important code line specifying the ExcelFilteredColumns:
FilterDescriptor filterDescriptor =
new
FilterDescriptor();
filterDescriptor.PropertyName =
"Title"
;
filterDescriptor.Value =
"Sales Representative"
;
filterDescriptor.Operator = FilterOperator.IsNotEqualTo;
CompositeFilterDescriptor cfd =
new
CompositeFilterDescriptor();
cfd.LogicalOperator = FilterLogicalOperator.And;
cfd.FilterDescriptors.Add(filterDescriptor);
cfd.IsFilterEditor =
true
;
this
.radGridView1.FilterDescriptors.Add(cfd);
this
.radGridView1.MasterTemplate.ExcelFilteredColumns.Add(
this
.radGridView1.Columns[
"Title"
]);
Now, you are supposed to achieve the desired result. I have attached my sample project for your reference.
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Telerik by Progress
Thank you Dess! The last line did the trick!
Issue resolved... Thanks again!