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

Binding between RadComboBox & RadGridView

2 Answers 140 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
ENTERPRISE INTERNATIONAL SAS
Top achievements
Rank 1
ENTERPRISE INTERNATIONAL SAS asked on 29 Oct 2010, 10:35 PM
Hi!

I have a details panel that show item selected from radgridview. Main DataContext = DataTable.DefaultView named VistaDatos. GridView is like this:

<telerik:RadGridView x:Name="grdGridConsulta" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding VistaDatos}" Margin="21,15.675,18,23" ShowGroupPanel="False"
                     HorizontalAlignment="Stretch" VerticalAlignment="Stretch" AutoGenerateColumns="False" ColumnWidth="Auto" IsReadOnly="True"
                     Style="{StaticResource Estilo1GridView}"
                     SelectionChanged="grdGridConsulta_SelectionChanged">
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn Header="{x:Static resx:resxUsuarios.lblID}" DataMemberBinding="{Binding CA001, Mode=TwoWay}" UniqueName="CA001" HeaderCellStyle="{StaticResource GridViewHeaderCellStyle1}" HeaderTextAlignment="Center"/>
        <telerik:GridViewDataColumn Header="{x:Static resx:resxUsuarios.lblNivel}" DataMemberBinding="{Binding CA006, Mode=TwoWay}" UniqueName="CA006" HeaderCellStyle="{StaticResource GridViewHeaderCellStyle1}" HeaderTextAlignment="Center"/>
        <telerik:GridViewDataColumn Header="{x:Static resx:resxUsuarios.lblNivelDescrip}" DataMemberBinding="{Binding CA006_DESCRIPCION, Mode=TwoWay}" UniqueName="CA006_DESCRIPCION" HeaderCellStyle="{StaticResource GridViewHeaderCellStyle1}" HeaderTextAlignment="Center"/>                            </telerik:RadGridView.Columns>
</telerik:RadGridView>

In details panel I have some controls, most important this:

<TextBlock x:Name="lblNivel" Text="{x:Static resx:resxUsuarios.lblNivel}" Style="{StaticResource Estilo1Etiqueta}" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="20,119.953,0,0" Padding="3,5,0,5" Height="27" Width="109"/>
<telerik:RadComboBox x:Name="cbxNivel" Tag="TABLA_PRINCIPAL" SelectedValuePath="CA001" DisplayMemberPath="CA003" ItemsSource="{cl:ColeccionItems IdOrigenDatos={x:Static sp:Publicos.CN_SIS_ESTADOS}, TipoAcceso=StoredProcedure, Parametros={StaticResource ParametrosSpNivelesUsuario}}" EmptyText="{x:Static kernel:resxMensajes.msjSeleccione}" Validation.ErrorTemplate="{StaticResource PlantillaErrores}" IsSynchronizedWithCurrentItem="True" IsEditable="False" TabIndex="3" HorizontalAlignment="Stretch" Margin="133,119.953,119,0" VerticalAlignment="Top" Height="27">
                                <telerik:RadComboBox.SelectedValue>
                                    <Binding ElementName="grdGridConsulta" Path="SelectedItem.CA006" Mode="TwoWay" UpdateSourceTrigger="Explicit">
                                        <Binding.ValidationRules>
                                            <cl:ReglaDatoRequerido MensajeError="{lr:RecursoIdioma IDRecurso=msjErrorDatoRequerido, Parametro={Binding Text, ElementName=lblNivel}, TipoRecursoIdioma=GLOBAL}"/>
                                        </Binding.ValidationRules>
                                    </Binding>
                                </telerik:RadComboBox.SelectedValue>
</telerik:RadComboBox>

ItemsSource code is CA001, ItemsSource Description si CA003 in radComboBox,  When I Update source radgridView, binding works fine, but I don´t know how to do to udpate description or text from radComboBox to this gridViewDataColum: 

<telerik:GridViewDataColumn Header="{x:Static resx:resxUsuarios.lblNivelDescrip}" DataMemberBinding="{Binding CA006_DESCRIPCION, Mode=TwoWay}" UniqueName="CA006_DESCRIPCION" HeaderCellStyle="{StaticResource GridViewHeaderCellStyle1}" HeaderTextAlignment="Center"/>

I tried something like this:

<telerik:RadComboBox x:Name="cbxNivel" Tag="TABLA_PRINCIPAL" SelectedValuePath="CA001" DisplayMemberPath="CA003" ItemsSource="{cl:ColeccionItems IdOrigenDatos={x:Static sp:Publicos.CN_SIS_ESTADOS}, TipoAcceso=StoredProcedure, Parametros={StaticResource ParametrosSpNivelesUsuario}}" EmptyText="{x:Static kernel:resxMensajes.msjSeleccione}" Validation.ErrorTemplate="{StaticResource PlantillaErrores}" IsSynchronizedWithCurrentItem="True" IsEditable="False" TabIndex="3" HorizontalAlignment="Stretch" Margin="133,119.953,119,0" VerticalAlignment="Top" Height="27">
    <telerik:RadComboBox.SelectedValue>
        <Binding ElementName="grdGridConsulta" Path="SelectedItem.CA006" Mode="TwoWay" UpdateSourceTrigger="Explicit">
            <Binding.ValidationRules>
                <cl:ReglaDatoRequerido MensajeError="{lr:RecursoIdioma IDRecurso=msjErrorDatoRequerido, Parametro={Binding Text, ElementName=lblNivel}, TipoRecursoIdioma=GLOBAL}"/>
            </Binding.ValidationRules>
        </Binding>
    </telerik:RadComboBox.SelectedValue>
    <telerik:RadComboBox.Text>
        <Binding ElementName="grdGridConsulta" Path="SelectedItem.CA006_DESCRIPCION" Mode="TwoWay" UpdateSourceTrigger="Explicit"/>
    </telerik:RadComboBox.Text>
</telerik:RadComboBox>

but it doesn´t work.

Can you help me about this???

thanks

2 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 03 Nov 2010, 11:25 AM
Hello Ramiro,

How about handling the SelectionChanged event of the RadComboBox ?
If you subscribe to this event , then you should be able with a few lines of code in the selection changed event handler to update the RadGridView data.

As a side note:
I am not sure why the current setup does not work . If I had the project or a small repro version of the issue , I could perform a debugging session on it and give a more precise answer.

In case you are capable of sending me such repro I will be glad to have a look, otherwise you may try the approach with the selection changed event .

Best wishes,
Pavel Pavlov
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
0
ENTERPRISE INTERNATIONAL SAS
Top achievements
Rank 1
answered on 06 Nov 2010, 05:09 PM
hI!

I found by myself solution about this scenario!!!!


thanks for your help!
Tags
General Discussions
Asked by
ENTERPRISE INTERNATIONAL SAS
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
ENTERPRISE INTERNATIONAL SAS
Top achievements
Rank 1
Share this question
or