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

DataForm MVVM

2 Answers 147 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Rajesh
Top achievements
Rank 1
Rajesh asked on 21 Nov 2011, 02:50 AM

Hello,
I go through your documents and online samples, but didn't find any DataForm sample with  MVVM pattern, I m trying to  following code for same, but it not able to add new item and it not synchronising  with grid view. can u provide a sample code for this ? thanks in advance

 

public ObservableCollection<Employee> SofiaCarRentalDomainContextCollection
{
    get { return _productionDataCollection; }
    set
    {
        _productionDataCollection = value;
        RaisePropertyChanged("SofiaCarRentalDomainContextCollection");
        EnableCommands();
    }
}

 

<telerik:RadGridView x:Name="RadGridView1" ItemsSource="{Binding SofiaCarRentalDomainContextCollection}" MinHeight="100" MaxHeight="500" Width="600" Height="200"
                      CanUserFreezeColumns="False" RowIndicatorVisibility="Collapsed" />
 <telerik:RadDataForm  AutoCommit="True"
     Width="600" x:Name="myRadDataForm" ItemsSource="{Binding SofiaCarRentalDomainContextCollection}" Header="Employee Details" Grid.Row="1" AutoGeneratingField="myRadDataForm_AutoGeneratingField">
     <i:Interaction.Triggers>
         <i:EventTrigger EventName="AddedNewItem">
             <E2C:EventToCommand  Command="{Binding AddNewCommand}" PassEventArgsToCommand="True"></E2C:EventToCommand>
         </i:EventTrigger>
         <i:EventTrigger EventName="EditEnded">
             <E2C:EventToCommand  Command="{Binding SaveCommand}" PassEventArgsToCommand="True"></E2C:EventToCommand>
         </i:EventTrigger>
     </i:Interaction.Triggers>
 </telerik:RadDataForm>

2 Answers, 1 is accepted

Sort by
0
Chetan
Top achievements
Rank 1
answered on 19 Dec 2012, 09:01 AM

I am also having same problem with 2012 Q3 sp1 release.
Do not know steps to invoke EndEdit event in MVVM ICOMMAND

<telerik:RadGridView x:Name="radGridview"
                            ItemsSource="{Binding AllItems}" SelectedItem="{Binding SelectedItem,Mode=TwoWay}" Grid.Row="0" 
                              AutoGenerateColumns="True"    
                            IsReadOnly="True" HorizontalContentAlignment="Stretch" 
                            >
           <telerik:RadGridView.Columns>
               <telerik:GridViewToggleRowDetailsColumn>
               </telerik:GridViewToggleRowDetailsColumn>
           </telerik:RadGridView.Columns>
           <telerik:RadGridView.RowDetailsTemplate>
               <DataTemplate>
                   <telerik:RadDataForm Grid.Row="0"
                            Name="clubsForm" CurrentItem="{Binding}" Margin="5">
                       <i:Interaction.Triggers>
                           <i:EventTrigger EventName="EditEnded" >
                               <i:InvokeCommandAction Command="{Binding EditEndedCommand}"  CommandParameter="{Binding ElementName=clubsForm, Path=CurrentItem}" />
                           </i:EventTrigger>
                       </i:Interaction.Triggers>
                   </telerik:RadDataForm>
               </DataTemplate>
           </telerik:RadGridView.RowDetailsTemplate>
       </telerik:RadGridView>

Here EditEndedCommand is not hit in view model

Private _ic1 As ICommand
   Public ReadOnly Property EditEndedCommand As ICommand  ' System.Windows.Input.ICommand
       Get
           If _ic1 Is Nothing Then
               _ic1 = New RelayCommand(AddressOf EditEnded_Click)
           End If
           Return _ic1
       End Get
   End Property

please suggest..
0
Ivan Ivanov
Telerik team
answered on 21 Dec 2012, 02:47 PM
Hello,

Can you please check whether you have any BIndingExpressionPath errors in your Output at runtime. In case the issue persists, I would kindly ask you to send us a repro project that we would be able to debug on our side and locate the issue.

All the best,
Ivan Ivanov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
DataForm
Asked by
Rajesh
Top achievements
Rank 1
Answers by
Chetan
Top achievements
Rank 1
Ivan Ivanov
Telerik team
Share this question
or