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

Accessing controltemplate in field

4 Answers 74 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
NS
Top achievements
Rank 1
NS asked on 03 Jul 2008, 02:12 PM
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

4 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 04 Jul 2008, 02:22 PM

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
0
NS
Top achievements
Rank 1
answered on 14 Jul 2008, 08:03 AM
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
0
Accepted
Milan
Telerik team
answered on 15 Jul 2008, 09:56 AM

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
0
NS
Top achievements
Rank 1
answered on 15 Jul 2008, 02:02 PM
tnx,

this made my day
Tags
General Discussions
Asked by
NS
Top achievements
Rank 1
Answers by
Milan
Telerik team
NS
Top achievements
Rank 1
Share this question
or