I have a XamDataGrid to display data.
In the ui screen if i update a value, it updates the following
foreach (ViewSetData vsData in paramViewSetVM.CurrentParamsData){
for (int i = 0; i < vsData.ParameterData.Rows.Count; i++)
{ if (vsData.ParameterData.Rows[i]["Parameter_Key"].ToString() == paramKey && vsData.ParameterData.Rows[i]["SelCritInstIds"].ToString() == attachedTo) {
vsData.ParameterData.Rows[i]["Default_Param_Value"] = cmb.DisplayValue.ToString(); vsData.ParameterData.Rows[i]["Default_Param_Version"] = dr[0]["ParameterVersion"].ToString(); found = true; break; } }
if (found) break; }
when i save, following code is executed and the data source here has correct updated values.
foreach (UIElement element in panel.Children) { if (element.GetType() == typeof(Expander)) { tempXGrid = null; Expander tempEx = element as Expander; tempXGrid = tempEx.Content as XamDataGrid;
if (firstLoop) { finalData = ((DataView)tempXGrid.DataSource).Table.Clone(); firstLoop = false; } finalData.Merge(((DataView)tempXGrid.DataSource).Table); } }
But there is one more way to update the values from ui through the excel sheet. Once i do that the following code runs
paramViewSetVM.CurrentParamsData.Clear(); StackPanel panel = FindName("dataGridPanel") as StackPanel;
// Update the view with the latest data foreach (UIElement element in panel.Children) { if (element.GetType() == typeof(Expander)) { Expander tempEx = element as Expander; XamDataGrid tempXGrid = tempEx.Content as XamDataGrid;
foreach (ViewSetData vsData in tmpvsData) { if (vsData.ViewSetName == tempEx.Header.ToString()) { tempXGrid.DataSource = vsData.ParameterData.Copy().DefaultView; break; } } } }
tmpvsData.ForEach(vs => { paramViewSetVM.CurrentParamsData.Add(new ViewSetData(vs.ViewSetName, vs.ParameterData.Copy())); }); // Put the data back in the bound vm data
MainGrid.IsEnabled = true; tmpvsData.Clear(); importSummaryBrdr.Visibility = System.Windows.Visibility.Collapsed; MsgPopup.Placement = System.Windows.Controls.Primitives.PlacementMode.MousePoint; MsgPopup.StaysOpen = false; btnSaveActivate.IsEnabled = true; btnSaveNotReady.IsEnabled = true; btnSaveReady.IsEnabled = true; btnImport.IsEnabled = true; lblInfo.Content = "Parameters import complete. Recipe will be created with these updated values."; MsgPopup.IsOpen = true;
Again when i save the data source has correct value.
foreach (UIElement element in panel.Children){if (element.GetType() == typeof(Expander)){tempXGrid = null;Expander tempEx = element as Expander;tempXGrid = tempEx.Content as XamDataGrid;
if (firstLoop){finalData = ((DataView)tempXGrid.DataSource).Table.Clone();firstLoop = false;}finalData.Merge(((DataView)tempXGrid.DataSource).Table);}}
After updating the values from the excel sheet, the data source for xamdatagrid has correct values. But if after this I try to update the value like in the first way, the "ParameterData" has correct values
{if (vsData.ParameterData.Rows[i]["Parameter_Key"].ToString() == paramKey && vsData.ParameterData.Rows[i]["SelCritInstIds"].ToString() == attachedTo){
vsData.ParameterData.Rows[i]["Default_Param_Value"] = cmb.DisplayValue.ToString();vsData.ParameterData.Rows[i]["Default_Param_Version"] = dr[0]["ParameterVersion"].ToString();found = true;break;}}
if (found)break;}
Can anyone please help. I am stuck in this.
Any help is greatly appreciated!!
Thanks in advance :)
Hello Arpita,
There is DataPresenterCommands.EndEditModeAndCommitRecord command that could be executed in order to end the edit mode. Gergana has shared a sample for the same here http://ko.infragistics.com/community/forums/t/92109.aspx
Another approach is to call EndEditMode method for the editor
textEditor1.EndEditMode( true, false );
http://help.infragistics.com/Help/Doc/WPF/2016.1/CLR4.0/html/InfragisticsWPF4.Editors.v16.1~Infragistics.Windows.Editors.ValueEditor~EndEditMode.html
Feel free to let me know if you need additional assistance.
Hi Maria,
Can you please suggest me how to exit edit mode?
Thanks.
The DataItemUpdateTrigger was introduced with version 13.2 and it could be used with all later versions. Since you are using 11.2 you need to exit edit mode to update the value.
Can you please tell from which version is this property introduced? We are on version 11.2.
In your scenarios the values seem to stop updating when they are changed from the UI? Is the editor still in edit mode on your last update? Please note that in order to update the value in the source the editor should exit the edit mode by pressing enter or selecting another cell.
You can also set FieldSettings.DataItemUpdateTrigger property to OnCellValueChange to force the update operation.
Please feel free to let me know if you have any other questions or concerns.