Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
200
Missing data in xamdatagrid when it is scrolled
posted

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://ko.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