When I am using the datagrid and enter a value in a cell and click save the value I just entered is lost. Only when I move focus into another cell will the value get saved.
I tried setting the updatesourcetrigger=Propertychanged also but still it's not working . I have written the code below:
<
Controls1:LipperGrid GroupByAreaLocation="None" Margin="0" Width="580" BorderThickness="0" AutoFit="False" HorizontalAlignment="Stretch" DataSource="{Binding PSNDCAssetAllocation}" Theme="Office2k7Silver" x:Name="lstNonDCAssets1" CellUpdated="lstNonDCAssets1_CellUpdated" CellUpdating="lstNonDCAssets1_CellUpdating" EditModeValidationError="lstNonDCAssets1_EditModeValidationError">
<DataPresenter:FieldSettings AllowEdit="False" LabelClickAction="Nothing" CellWidth
="200" />
</DataPresenter:Field
>
<DataPresenter:Field Name="Value" Label
="Assets value in %">
<DataPresenter:Field.Settings
<DataPresenter:FieldSettings CellWidth="20" LabelClickAction="Nothing" EditorType="{x:Type igEditors:XamTextEditor}" AllowEdit="True" CellClickAction
="EnterEditModeIfAllowed">
<DataPresenter:FieldSettings.EditorStyle
<Style TargetType="{x:Type igEditors:XamTextEditor
}">
<Style.Setters
<Setter Property="ValueType" Value="{x:Type sys:Decimal
}"/>
<Setter Property="Format" Value
="######0.###"/>
<Setter Property="HorizontalAlignment" Value
="Center"/>
</Style.Setters
</Style
</DataPresenter:FieldSettings.EditorStyle
</DataPresenter:FieldSettings
</DataPresenter:Field.Settings
<DataPresenter:Field Name="ModDate" Label
="Last Modified Date" >
="20"/>
<DataPresenter:Field Name="ModUser" Label
="Last Modified By" >
</DataPresenter:FieldLayout.Fields
</DataPresenter:FieldLayout
</Controls1:LipperGrid.FieldLayouts
</Controls1:LipperGrid
Hello,
This is because the Editor in that cells updates the underlying data object when it ends edit mode. By default, the edit mode ends when the editor loses focus. If you want the data to be updated immediately, when clicking the Save Button, you have to call EndEditMode(...) method of the ValueEditor of that cell.
Please let me know if you have any more questions on this.
Save button is in different file. How I should set set the EndEditMode explicitly? Save button is common for six screens. Each screen has grid and I am facing the same issue in all grids
Sorry, Didn't mean to sugguest above answer. Anyway, I ran into the same problem using composite application blocks. For some reason, the controls in a the current form don't recognize when a ribbon button like Save has been pressed on the ribbon bar. Thus, the lostfocus event doesn't fire on the cell editor and the change is lost. I was able to set the update mode for textboxes in a grid by doing the following:
=DataContext.InstancesViewModel.NameEnabled}"/>
=PropertyChanged}" />
Then I define the grid field for the name property as:
="Name" >
Now, the update occures when the text is changed, not when the focus is lost on the cell editor. I assume this will work for othe editor as well.
Shane
I assumed that your save button is inside the CellValuePresenter.
In this case, I do not see a reason why the value would not be updated, because by clicking the save button, which is somewhere outside, the editor will lose its focus and update the value.
If you have a sample project, reproducing this issue, please attach it to your next post so that we can look into it.