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

Problem populating a RadDataFilter

3 Answers 106 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Gen
Top achievements
Rank 1
Gen asked on 30 Mar 2011, 03:56 PM
Hi,
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

Sort by
0
Rossen Hristov
Telerik team
answered on 31 Mar 2011, 09:23 AM
Hi Gen,

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,

Ross
the Telerik team
0
Gen
Top achievements
Rank 1
answered on 05 Apr 2011, 03:15 PM
Hello,
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"/>
When I plug a converter to the SelectedValue, the Value sent is correct. But it wont display...

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));
with:
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
0
Rossen Hristov
Telerik team
answered on 06 Apr 2011, 08:35 AM
Hi 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.

Best wishes,
Ross
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Gen
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Gen
Top achievements
Rank 1
Share this question
or