Accessing controltemplate in field

5 posts, 1 answers
  1. NS
    NS avatar
    189 posts
    Member since:
    Jan 2007

    Posted 03 Jul 2008 Link to this post

    Hi,

    I have a controltemplate on a column.
    <ControlTemplate x:Key="ComboBoxColumnTemplateReportService" TargetType="{x:Type Telerik:GridViewCell}">  
                <StackPanel Orientation="Horizontal">  
                        <ComboBox Width="150" Height="Auto" VerticalAlignment="Center" Margin="0,0,0,0" x:Name="dtcReportService" DataContext="{StaticResource objectDataProviderReportServices}" ItemsSource="{Binding}" DisplayMemberPath="Name"  /> 
                        <ComboBox Width="150" Height="Auto" VerticalAlignment="Center" Margin="8,0,0,0" x:Name="dtcPrinter" DataContext="{Binding Path=SelectedItem.Printers, ElementName=dtcReportService, Mode=Default}" ItemsSource="{Binding}" DisplayMemberPath="Name" /> 
                        <ComboBox Width="150" Height="Auto" VerticalAlignment="Center" Margin="8,0,0,0" x:Name="dtcPrinterTray" DataContext="{Binding Path=SelectedItem.PrinterTrays, ElementName=dtcPrinter, Mode=Default}" ItemsSource="{Binding}" DisplayMemberPath="Description" /> 
                </StackPanel> 
            </ControlTemplate> 

    Now i want to access the template while looping my rows so i can get the selected values from my comboboxes (per row).

    How can i do this?

    Regards
  2. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 04 Jul 2008 Link to this post

    Hello NS,

    I am wondering if the rows that you are referring to are the rows of the RadGridView. If that is the case you should keep in mind that the grid uses virtualization and only a subset of all rows is rendered at any given moment.
    Could you give us more information about the functionality that you are trying implement so that we can try to workd out a solution for you?

    Greetings,
    Milan
    the Telerik team


    Instantly find answers to your questions at the new Telerik Support Center
  3. NS
    NS avatar
    189 posts
    Member since:
    Jan 2007

    Posted 14 Jul 2008 Link to this post

    So my problem is:

    i have 3 columns

    Server, printer and tray

    No i want in each row a datacombo where i can choose the server, printer and tray.

    When you choose a server it filters out the values in the printer combo and the printer combo filters the items in the tray combo.

    When the data is loaded the selected item of the combos is filled in by the value of the column in that row.

    Any suggestions
  4. Answer
    Milan
    Admin
    Milan avatar
    1989 posts

    Posted 15 Jul 2008 Link to this post

    Hi NS,

    We have created a sample application that simulates the functionality that you are trying to implement (you can find it in the attached zip file). You were pretty much on the right track with you custom GridViewCell template. The only problem was that you set the DataContext of the ComboBoxes, thus blocking their access to the DataRecords that are generated by our data engine.

    Here are the bindings for the dtcReportService combo that we have come up with:

    <ComboBox   
        x:Name="dtcReportService"   
        ItemsSource="{Binding Source={StaticResource objectDataProviderReportServices}, IsAsync=False}" 
        DisplayMemberPath="Name" 
        SelectedValuePath="Name" 
        SelectedValue="{Binding Path=Data[Server], IsAsync=True}"/> 

    * We set the IsAsynch property to ensure that the SelectedValue binding will be applied after the binding for ItemsSource.

    Similarly to what you have done, we use the objectDataProviderReportServices as ItemsSource, but without setting it as DataContext. Note that now we have a DataRecord as DataContext and we use it to provide the SelectedValue of the ComboBox. The other ComboBoxes are defined in a similar manner.

    The real benefit of this binding setup is that the data entities will be updated automatically and you will only have to loop throught the data elements, not their visual representations, in order to collect the information that you require.

    Sincerely yours,
    Milan
    the Telerik team


    Instantly find answers to your questions at the new Telerik Support Center
  5. NS
    NS avatar
    189 posts
    Member since:
    Jan 2007

    Posted 15 Jul 2008 Link to this post

    tnx,

    this made my day
Back to Top