Binding to RadGrid shows "Data" not "Columns"?

3 posts, 0 answers
  1. plusHR
    plusHR avatar
    58 posts
    Member since:
    Aug 2012

    Posted 11 Apr 2011 Link to this post

    Hi.

    I'm trying to use the DataFilter control to filter data in the RadGrid [bound to RIA]. I have the following;

    <telerik:RadDataFilter Name="radDataFilter"
                                         Grid.Row="0"
                                         Grid.Column="3"
                                         Source="{Binding Items, ElementName=radGridView1}"
                                         Margin="1"
                                         telerik:StyleManager.Theme="Windows7"
                                         AutoGenerateItemPropertyDefinitions="True">
                       
                  </telerik:RadDataFilter>

    However when I use the control it shows the actual RIA data columns and the entity names. I only want it to show the columns that have been set-up within the actual grid and to show the grid names/values. Any ideas?
  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 11 Apr 2011 Link to this post

    Hi Paul,

    RadGridView and RadDataFilter are two separate controls and if you have hidden some column on the UI level in RadGridView then RadDataFilter has no "magic way" of knowing that you have done this. They share the same data source, but the UI of each on is its own. So you have two options

    You should use Data Annotations on your business object properties. In this way you can tell both RadGridView and RadDataFilter (in fact any other control aware of these annotations) whether to show these properties or not. Both controls will respect these data annotations. 

    RadGridView will respect the AutoGenerateField data annotation and if it is false it will not generate a column for this property. RadDataFilter will respect both the AutoGenerateField and AutoGenerateFilter data annotations, so if it encounters either with a value of false, it will not display the respective property in the UI.

    Using Data Annotations is the proper way of handling your requirement.

    In case you are manually defining RadGridView's columns instead of using data annotations, then you will need to do the same thing for RadDataFilter. Turn off its AutoGenerateItemPropertyDefinitions property and then manually add the ItemPropertyDefinitions that you desire. It is the same concept as with RadGridView's columns, only they are not called Columns but ItemPropertyDefinitions. Here is the correspondence:

    RadGridView.AutoGenerateColumns <=> RadDataFilter.AutoGenerateItemPropertyDefinitions
    RadGridView.Columns <=> RadDataFilter.ItemPropertyDefinitions

    But again, the proper way to tell all controls what to show and what not to show would be to use the Data Annotations.

    I hope this helps. Let me know if you have any questions.

    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
  3. DevCraft banner
  4. plusHR
    plusHR avatar
    58 posts
    Member since:
    Aug 2012

    Posted 11 Apr 2011 Link to this post

    Hi, thanks for the prompt response.

    We cant use Data Annotations as we have a dynamic multi-lingual branding system and therefore this is dynamically loaded to the Silverlight client to support changing of text fields etc. 

    I am having problems setting up the ItemPropertyDefinitions, perhaps you can point me in the right direction. Snippet of my Grid code;

    <telerik:RadGridView x:Name="radGridView1"
                              telerik:StyleManager.Theme="Windows7"
                              IsReadOnly="True"
                              AutoGenerateColumns="False"
                              RowIndicatorVisibility="Collapsed"
                              GroupPanelForeground="#FF1E395B"
                              Margin="0"
                              GroupPanelStyle="{StaticResource GridViewGroupPanelStyle}"
                              BorderBrush="#FFA0AFC3"
                              Grid.Row="1"
                              ItemsSource="{Binding}"
                              IsSynchronizedWithCurrentItem="True"
                              RowStyleSelector="{StaticResource GridViewStatusSelector}"
                              ShowGroupPanel="False"
                              Cursor="Hand">
             <telerik:RadGridView.Columns>
                 <telerik:GridViewDataColumn Header="Year"
                                             Width="Auto"
                                             DataMemberBinding="{Binding Path=data_PERFORMANCE_YEARS.yeartext2}" />
                 <telerik:GridViewDataColumn Header="Team Member"
                                             IsFilterable="True"
                                             Width="*"
                                             DataMemberBinding="{Binding Path=data_PERSON.fullname}" />

    Then I want to add the search for "Team Member" which is "data_PERSON.fullname", thus my data-filter is setup below, however I get an error when selecting the data filter in the client;
    <telerik:RadDataFilter Name="radDataFilter"
                                          Grid.Row="0"
                                          Grid.Column="3"
                                          Source="{Binding Items, ElementName=radGridView1}"
                                          Margin="1"
                                          telerik:StyleManager.Theme="Windows7"
                                          AutoGenerateItemPropertyDefinitions="False">
                       <telerik:RadDataFilter.ItemPropertyDefinitions>
                           <datafilter:ItemPropertyDefinition PropertyName="data_PERSON.fullname"
                                                              PropertyType="{Binding String}"
                                                              DisplayName="Team Member"></datafilter:ItemPropertyDefinition>
                       </telerik:RadDataFilter.ItemPropertyDefinitions>
                   </telerik:RadDataFilter>


Back to Top