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

GridViewComboBoxColumn on change to update two other columns

4 Answers 365 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 14 Jan 2015, 08:21 PM
Hello,

I'm a noob to WPF. I inherited an MVVM WPF project using Caliburn.Micro.

I have this gridview:
<telerik:RadGridView Margin="10"
                                         CanUserFreezeColumns="False"
                                         MaxHeight="300"
                             RowIndicatorVisibility="Collapsed"
                             IsReadOnly="False"
                             ScrollMode="Deferred"
                             BeginningEdit="RadGridView_BeginningEdit"
                             CellEditEnded="RadGridView_CellEditEnded"
                             ScrollViewer.PanningMode="VerticalFirst"
                             ScrollViewer.HorizontalScrollBarVisibility="Visible"
                             ItemsSource="{Binding SelectedCollectionPatient.CollectionTests}"
                             SelectedItem="{Binding SelectedCollectionTest}"
                             AutoGenerateColumns="False"
                             IsFilteringAllowed="False"
                             ShowGroupPanel="False"
                                         >
 
                        <telerik:RadGridView.Columns>
                                                         
                            <telerik:GridViewComboBoxColumn ItemsSource="{Binding Path=DataContext.SelectedCollectionPatient.CurrentStatusList,
                                                RelativeSource={RelativeSource FindAncestor,
                                                AncestorType={x:Type Window}}}"
                                                Width="145" IsReadOnly="False"
                                                DataMemberBinding="{Binding CurrentStatus}"
                                                Header="Collection Status"
                                                UniqueName="CurrentStatus" >
                            </telerik:GridViewComboBoxColumn>
                             
                            <telerik:GridViewDataColumn Width="*" IsReadOnly="False"
                                            DataMemberBinding="{Binding CollectionTime, StringFormat='{}{0:hh:mm tt}' }">
                                <telerik:GridViewDataColumn.CellEditTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            
                                            <telerik:RadMaskedDateTimeInput Margin="0"
                                                                     telerik:TouchManager.IsTouchHitTestVisible="False"
                                                                     EmptyContent="No Time Entered"
                                                                     VerticalContentAlignment="Center"
                                                                     Height="50" Width="150" Mask="hh:mm tt"
                                                                     Value="{Binding CollectionTime, UpdateSourceTrigger=PropertyChanged}">
                                            </telerik:RadMaskedDateTimeInput>
 
                                            <telerik:RadButton Command="{Binding RelativeSource={RelativeSource FindAncestor,
                                                            AncestorType={x:Type Window}},
                                                            Path=DataContext.SetCurrentTimeCommand}" Width="35" Margin="0">
                                                <Image Source="/HomeCollections.UI;component/Images/Icons/time.png" Width="16" Stretch="None"></Image>
                                            </telerik:RadButton>
                                        </StackPanel>
                                    </DataTemplate>
                                </telerik:GridViewDataColumn.CellEditTemplate>
                            </telerik:GridViewDataColumn>
 
                            <telerik:GridViewComboBoxColumn ItemsSource="{Binding SelectedCollectionPatient.ReasonList}"                                                         
                                                Width="165" IsReadOnly="False"
                                                DisplayMemberPath="ReasonText"
                                                SelectedValueMemberPath="UncollectedReasonId"
                                                DataMemberBinding="{Binding UncollectedReasonId}"
                                                Header="Uncollected Reason">
                            </telerik:GridViewComboBoxColumn>
 
                        </telerik:RadGridView.Columns>
                    </telerik:RadGridView>

When the CurrentStatus combo box column is changed, I want to check the status and:
1) update or clear the CollectionTime  (the masked input)
2) update or clear the UncollectedReason column

I'm current trying to do it in the RadGridView_CellEditEnded event... but haven't been able to figure it out.
if (e.Cell.Column.UniqueName == "CurrentStatus")
            {
                if (e.NewData != e.OldData)
                {
}
}


Thanks.

4 Answers, 1 is accepted

Sort by
0
Accepted
Dimitrina
Telerik team
answered on 15 Jan 2015, 03:22 PM
Hello,

You can check the Handle SelectionChanged for the GridViewComboBoxColumn article. Once the selection has changed, you can proceed further with your additional information.

Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Greg
Top achievements
Rank 1
answered on 15 Jan 2015, 10:59 PM
Thanks. Got it working perfectly.

I had to to do some clever coding to figure out which combobox was firing. Not sure why uniquename is not there.
0
Sandip
Top achievements
Rank 1
answered on 30 Jul 2020, 05:55 PM

Can you please help me with the code as I am facing the same issue. Like I have radgridview and binded it using list and autogeneratedcolumns = false and I have one dropdown column and while changing I want to update another column with certain value. So the value updated in the Itemsource but Grid not updated and showing old value.

As the solution page not opening. Can you please help me on this.

0
Vladimir Stoyanov
Telerik team
answered on 04 Aug 2020, 10:38 AM

Hello Sandip,

I am adding the correct link for the mentioned article: Handle SelectionChanged for GridViewComboBoxColumn.

I hope you find this helpful.

Regards,
Vladimir Stoyanov
Progress Telerik

Tags
GridView
Asked by
Greg
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Greg
Top achievements
Rank 1
Sandip
Top achievements
Rank 1
Vladimir Stoyanov
Telerik team
Share this question
or