I have a problem modifying an existing filter.
I have a popup with a RadDataFilter, a RadGridView and a RadDataPager, bound to my data. Once I added some criterias to my filter, I can save it for later. I have made custom comboBox templates for some of the filter criterias. When I reopen my popup to edit the filter, the correct criterias are seen, but the comboBox don't have any value selected. If I save the filter like that, when I again re-open, it is empty.
I have a sample project that demonstrate my situation. Please let me know how I can send it to you.
Thank you,
Gen
3 Answers, 1 is accepted
You are the only one that can populate your editors, since you are their creator and owner. You can attach to the EditorCreated event, read what you have saved somewhere and apply it to your custom editors.
I hope this helps.
Best wishes,
the Telerik team
I am using the EditorCreated event. I based my code on this example (http://demos.telerik.com/silverlight/#DataFilter/CustomEditors).
I thought that the Binding would be enough to populate the combobox:
<DataTemplate x:Key="ComboBoxEditor"> <telerik:RadComboBox SelectedValue="{Binding Value, Mode=TwoWay, FallbackValue=null}" MinWidth="100" /> </DataTemplate> <utility:EditorTemplateSelector x:Key="EditorTemplateSelector"> <utility:EditorTemplateSelector.EditorTemplateRules> <utility:EditorTemplateRule PropertyName="TypeDesc" DataTemplate="{StaticResource ComboBoxEditor}" /> <utility:EditorTemplateRule PropertyName="StatusDesc" DataTemplate="{StaticResource ComboBoxEditor}" /> </utility:EditorTemplateSelector.EditorTemplateRules> </utility:EditorTemplateSelector> <!-- ... --> <telerik:RadDataFilter Name="radDataFilter" Margin="1" Height="250" Source="{Binding Path=PagedSource, ElementName=radDataPager1}" EditorTemplateSelector="{StaticResource EditorTemplateSelector}" EditorCreated="radDataFilter_EditorCreated"/> <telerik:RadGridView x:Name="radGridView" ItemsSource="{Binding Path=FilteredSource, ElementName=radDataFilter}" Height="300" Width="880" HorizontalAlignment="Left" RowDetailsVisibilityMode="Collapsed" AutoGenerateColumns="False" IsFilteringAllowed="False" > <!-- ... --> </telerik:RadGridView> <telerik:RadDataPager x:Name="radDataPager1" PageSize="20" Source="{Binding Path=DataGridFilterItems}" Width="880" DisplayMode="All" AutoEllipsisMode="Both" NumericButtonCount="10" IsTotalItemCountFixed="True" HorizontalAlignment="Left"/> Is there a way to manually set the value in the EditorCreated event? I can't find witch property to use.
Here is some more code sample.
private void radDataFilter_EditorCreated(object sender, EditorCreatedEventArgs e) { switch (e.ItemPropertyDefinition.PropertyName) { case "TypeDesc": ((RadComboBox)e.Editor).ItemsSource = listTypes; ((RadComboBox)e.Editor).SelectedValue = "";//set value here break; case "StatusDesc": ((RadComboBox)e.Editor).ItemsSource = listStatus; ((RadComboBox)e.Editor).SelectedValue = "";//set value here break; } }And to populate the filter:
var serializer = new DataContractSerializer(typeof(FilterSet), new List<Type> { typeof(Filter) }); var encoding = new UTF8Encoding(); var stream = new MemoryStream(encoding.GetBytes(filter.Filter)); var fs = (FilterSet)serializer.ReadObject(stream); radDataFilter.FilterDescriptors.Clear(); radDataFilter.FilterDescriptors.LogicalOperator = fs.Operator; radDataFilter.FilterDescriptors.AddRange(GetFilterDescriptorsFromFilters(fs.Filters));public class IFilter { } public class FilterSet : IFilter { public List<IFilter> Filters; public FilterCompositionLogicalOperator Operator { get; set; } } public class Filter : IFilter { public bool IsCaseSensitive { get; set; } public string Member { get; set; } public object Value { get; set; } public FilterOperator Operator { get; set; } }Thanks,
Gen
Unfortunately, without having a project to debug I cannot guess why your combo-boxes will not pick up the selected value.
Can your try the following. When you get a reference to the combo in the radDataFilter_EditorCreated, can you attach to the RadComboBox.Loaded event and try to set the SelectedValue in its event handler.
Another thing you can try would be to set the SelectedIndex of the combo instead of setting the SelectedIValue.
If you can prepare a sample project that reproduces this, I will take a look at it to see what is wrong.
Ross
the Telerik team