thanks!
4 Answers, 1 is accepted
In order to provide you with an appropriate solution, I would need a bit more details. How do you calculate the values in the last column ? Do you use a GridViewExpressionColumn or do you follow an approach similar to this one ? May you verify if the CellEditEnded event is fired when filling up the values in the new item ? It would be great if you share any relevant code-snippets or send us a sample project simulating the issue.
Maya
the Telerik team
thx, Koren
Here is the relevant parts of the view model:
private void UpdateValue() { this.Value = this.Acres * this.YieldPerAcre * this.UnitPrice; } public double Acres { get { return _cropProductionRecord.Acres; } set { _cropProductionRecord.Acres = value; OnPropertyChanged("Acres"); UpdateValue(); } } public double YieldPerAcre { get { return _cropProductionRecord.YieldPerAcre; } set { _cropProductionRecord.YieldPerAcre = value; OnPropertyChanged("YieldPerAcre"); UpdateValue(); } } public double UnitPrice { get { return _cropProductionRecord.UnitPrice; } set { _cropProductionRecord.UnitPrice = value; OnPropertyChanged("UnitPrice"); UpdateValue(); } } public double Value { get { return _cropProductionRecord.Value; } set { _cropProductionRecord.Value = value; OnPropertyChanged("Value"); } } And the grid: <telerik:RadGridView DockPanel.Dock="Top" x:Name="grdCropProduction" ItemsSource="{Binding CropProductionRecords}" AutoGenerateColumns="False" IsFilteringAllowed="True" ShowGroupPanel="False" SelectionMode="Extended" ShowInsertRow="True" ActionOnLostFocus="None" CanUserInsertRows="True" CanUserDeleteRows="True" CanUserReorderColumns="False" IsReadOnly="False" CanUserFreezeColumns="False" CanUserResizeColumns="False" Deleting="grdCropProduction_Deleting" RowIndicatorVisibility="Collapsed" RowEditEnded="grdCropProduction_RowEditEnded" AddingNewDataItem="grdCropProduction_AddingNewDataItem"> <telerik:RadGridView.Columns> <telerik:GridViewColumn> <telerik:GridViewColumn.CellTemplate> <DataTemplate> <telerik:RadButton Content="Delete" Command="telerikGrid:RadGridViewCommands.Delete" CommandParameter="{Binding}" /> </DataTemplate> </telerik:GridViewColumn.CellTemplate> </telerik:GridViewColumn> <telerik:GridViewComboBoxColumn UniqueName="TransactionCode" Header="ATIGD" IsComboBoxEditable="True" DataMemberBinding="{Binding TransactionCodeID}" DisplayMemberPath="CodeDescription" SelectedValueMemberPath="TransactionCodeID" > <telerik:GridViewComboBoxColumn.EditorStyle> <Style TargetType="telerik:RadComboBox"> <Setter Property="OpenDropDownOnFocus" Value="true" /> </Style> </telerik:GridViewComboBoxColumn.EditorStyle> </telerik:GridViewComboBoxColumn> <telerik:GridViewComboBoxColumn Header="Ent #" IsComboBoxEditable="True" DataMemberBinding="{Binding FarmYearEnterpriseID}" DisplayMemberPath="CodeDescription" SelectedValueMemberPath="FarmYearEnterpriseID" ItemsSource="{Binding FarmYearEnterprises}"> <telerik:GridViewComboBoxColumn.EditorStyle> <Style TargetType="telerik:RadComboBox"> <Setter Property="OpenDropDownOnFocus" Value="true" /> </Style> </telerik:GridViewComboBoxColumn.EditorStyle> </telerik:GridViewComboBoxColumn> <telerik:GridViewDataColumn Header="O/R" DataMemberBinding="{Binding Owned}"> <telerik:GridViewDataColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Owned, Converter={StaticResource BooleanConverter}, ConverterParameter=OWNED}" /> </DataTemplate> </telerik:GridViewDataColumn.CellTemplate> </telerik:GridViewDataColumn> <telerik:GridViewDataColumn Header="Opr %" DataMemberBinding="{Binding OperatorPercent}" DataFormatString="{}{0:p}" IsFilterable="False" /> <telerik:GridViewDataColumn Header="Acres" Width="60" DataMemberBinding="{Binding Acres}" IsFilterable="False" /> <telerik:GridViewDataColumn Width="60" DataMemberBinding="{Binding YieldPerAcre}" IsFilterable="False"> <telerik:GridViewDataColumn.Header> <TextBlock Text="Yield Per Acre" TextWrapping="Wrap" /> </telerik:GridViewDataColumn.Header> </telerik:GridViewDataColumn> <!--<telerik:GridViewDataColumn Header="QuantityCodeID" DataMemberBinding="{Binding QuantityCodeID}" IsFilterable="False" />--> <telerik:GridViewDataColumn Width="60" DataMemberBinding="{Binding UnitPrice}" DataFormatString="{}{0:c}" IsFilterable="False"> <telerik:GridViewDataColumn.Header> <TextBlock Text="Unit Price" TextWrapping="Wrap" /> </telerik:GridViewDataColumn.Header> </telerik:GridViewDataColumn> <!--<telerik:GridViewExpressionColumn Header="$ Value" UniqueName="TotalValue" DataFormatString="{}{0:c}" />--> <telerik:GridViewDataColumn Header="$ Value" Width="60" DataMemberBinding="{Binding Value}" DataFormatString="{}{0:c}" IsFilterable="False" IsReadOnly="True" /> <telerik:GridViewDataColumn Width="60" DataMemberBinding="{Binding UnitWeight}" IsFilterable="False"> <telerik:GridViewDataColumn.Header> <TextBlock Text="Unit Weight" TextWrapping="Wrap" /> </telerik:GridViewDataColumn.Header> </telerik:GridViewDataColumn> <telerik:GridViewDataColumn Header="Tot Units" Width="60" DataMemberBinding="{Binding TotalUnits}" IsFilterable="False" /> <!--<telerik:GridViewExpressionColumn Header="Weight" UniqueName="TotalWeight" />--> <telerik:GridViewDataColumn Header="Weight" Width="60" DataMemberBinding="{Binding Weight}" IsFilterable="False" IsReadOnly="True" /> </telerik:RadGridView.Columns> </telerik:RadGridView>
Based on the code-snippets provided, I prepared a small application in an attempt to reproduce your scenario. However, I am not able to get the behavior you specified. May you take a look at my application and let me know in case of any discrepancies according to your requirements ? Feel free to change the sample in the way you want and send it back if necessary.
Maya
the Telerik team