GridViewComboBoxColumn on change to update two other columns

3 posts, 1 answers
  1. Greg
    Greg avatar
    17 posts
    Member since:
    Oct 2010

    Posted 14 Jan 2015 Link to this post

    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.

  2. Answer
    Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 15 Jan 2015 Link to this post

    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.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Greg
    Greg avatar
    17 posts
    Member since:
    Oct 2010

    Posted 15 Jan 2015 in reply to Dimitrina Link to this post

    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.
Back to Top