Hi,
I have a xamdatagrid with 4 fields, 3 of them are xamcombobox. I used to have problem with SelectedItemChanged event being triggered when data is loaded and managed to solve it with your help from this forum: http://es.infragistics.com/community/forums/p/62364/322218.aspx. Thank you so much.
I have another problem though. When I add new rows and use the scrollbar to scroll the data, data that are newly added (only the last field called Attribute Name) will disappear from UI. It's saved to the db but just dissappears from the UI.
Please help, here are my code. Thank you.
XAML Code:
<igDP:XamDataGrid Name="EventAttributeGrid" Style="{StaticResource XamGridStyleWithAdd}" MaxHeight="200" RecordUpdated="GeneralXamDataGrid_RecordUpdated" RecordAdded="GeneralXamDataGrid_RecordAdded" RecordsDeleting="GeneralXamDataGrid_RecordsDeleting"> <!--To enable sorting--> <igDP:XamDataGrid.FieldSettings> <igDP:FieldSettings LabelClickAction="Default" SortComparisonType="Default"/> </igDP:XamDataGrid.FieldSettings> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:FieldLayout.Fields> <igDP:UnboundField Label="Event Name" BindingPath="EventID" BindingMode="OneWay" Width="Auto" > <igDP:UnboundField.Settings> <igDP:FieldSettings> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsProvider" Value="{DynamicResource eventprovider}" /> <EventSetter Event="SelectedItemChanged" Handler="GeneralComboBox_SelectedItemChanged"/> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:UnboundField.Settings> </igDP:UnboundField>
<igDP:UnboundField Name="AreaName" Label="Area Name (Optional)" BindingPath="AreaId" BindingMode="OneWay" Width="Auto" > <igDP:UnboundField.Settings> <igDP:FieldSettings> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsProvider" Value="{DynamicResource attributeAreaNameprovider}" /> <EventSetter Event="SelectedItemChanged" Handler="GeneralComboBox_SelectedItemChanged"/> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:UnboundField.Settings> </igDP:UnboundField>
<igDP:UnboundField Name="AttributeNumber" Label="Attribute Number" BindingPath="AttributeId" BindingMode="OneWay" Width="Auto" > <igDP:UnboundField.Settings> <igDP:FieldSettings> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsProvider" Value="{DynamicResource attributeListprovider}" /> <!--<EventSetter Event="SelectedItemChanged" Handler="WFConfigurationAttributeNumber_SelectedItemChanged"/>--> <EventSetter Event="SelectedItemChanged" Handler="GeneralComboBox_SelectedItemChanged"/> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:UnboundField.Settings> </igDP:UnboundField>
<igDP:UnboundField Name="AttributeName" Label="Attribute Name" Width="Auto" BindingPath="AttributeList.AttributeName" BindingMode="OneWay"> <igDP:UnboundField.Settings> <igDP:FieldSettings AllowResize="False" AllowGroupBy="False" AllowRecordFiltering="False" AllowSummaries="False" AllowEdit="False"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:ValueEditor}"/> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:UnboundField.Settings> </igDP:UnboundField>
<igDP:UnboundField Name="deleteField"> <igDP:UnboundField.Settings> <igDP:FieldSettings AllowResize="False" AllowGroupBy="False" AllowRecordFiltering="False" AllowSummaries="False" CellWidth="20" LabelWidth="20" CellValuePresenterStyle="{StaticResource deleteButtonStyle}"/> </igDP:UnboundField.Settings> </igDP:UnboundField> </igDP:FieldLayout.Fields> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> </igDP:XamDataGrid>
C# code to bind the Camcoboeditor:
private void GeneralComboBox_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e) { XamComboEditor ce = (XamComboEditor)sender; if (!ce.IsMouseCaptureWithin && !ce.IsKeyboardFocusWithin) return;
XamDataGrid containerGrid; containerGrid = Styles.FindAncestorOrSelf<XamDataGrid>(ce);
switch (containerGrid.Name) {
case "EventAttributeGrid": if (e.NewValue is AreaOperationRange) selectedEventAttributeAreaID = ((AreaOperationRange)e.NewValue).AreaId; else if (e.NewValue is Event) selectedEventAttributeEventID = ((Event)e.NewValue).EventID; else if (e.NewValue is AttributeList) { selectedEventAttributeAttributeID = ((AttributeList)e.NewValue).AttributeId; AttributeList attr = e.NewValue as AttributeList; DataRecord dr = ce.DataContext as DataRecord; if (dr != null) dr.Cells["AttributeName"].Value = attr.AttributeName; } break;
} }
rgds,shan
Hello Shan,
It has been a while since you have made your post, in case you still need support I will be glad to assist you further. I suppose the other community members can benefit from this answer as well. I have been looking into your post, but since I cannot be completely sure how your data is organized I am not able to investigate this further for you, so if this is still an issue for you, could you please send an isolated sample project, where the issue is reproduced, so I can investigate it.
Feel free to write me if you have further questions.
Any update anyone? Thanks!
Any update? Thanks!