Welcome to the Xceed Community | Help
Community Search  
More Search Options

Xceed DataGrid: Insertion row doesn't add a row

Sort Posts: Previous Next
  •  04-27-2009, 2:59 AM Post no. 20559

    Xceed DataGrid: Insertion row doesn't add a row

    Hi,

    using th einsertion row, it happens that after filling editors with values and hit the enter key, all data disappear fron the insertion row but they are not added to the grid.

    I am using the grid in a MVVM pattern and I also tried using a DataGridCollectionViewSource that bind to an ObservableCollection.

    Here the xaml definition:

    <UserControl x:Class="Budano.Store.Views.CurrencyView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase"
        xmlns:xceedGrid="http://schemas.xceed.com/wpf/xaml/datagrid"
        xmlns:xceedViews="clr-namespace:Xceed.Wpf.DataGrid.Views;assembly=Xceed.Wpf.DataGrid"
        Width="500" >
        <Grid>
            <Grid.Resources>
                <xceedGrid:DataGridCollectionViewSource x:Key="CurrenciesCollectionViewSource" Source="{Binding Path=Currencies}"/>
            </Grid.Resources>
            <xceedGrid:DataGridControl
                Name="dataGridControl1"
                IsDeleteCommandEnabled="True"
                ItemsSource="{Binding Source={StaticResource CurrenciesCollectionViewSource}}"
                ReadOnly="{Binding Path=UIStatus, Converter={StaticResource UIStatusConverter}}"
                AutoCreateColumns="False"
                CellEditorDisplayConditions="CellIsCurrent"
                EditTriggers="BeginEditCommand, SingleClick, CellIsCurrent, ActivationGesture" ItemScrollingBehavior="Immediate" UpdateSourceTrigger="CellEndingEdit" NavigationBehavior="RowOrCell">
                <xceedGrid:DataGridControl.Columns>
                    <xceedGrid:Column FieldName="Code" Title="Valuta" Width="60" IsMainColumn="True">
                        <xceedGrid:Column.CellEditor>
                            <xceedGrid:CellEditor>
                                <xceedGrid:CellEditor.EditTemplate>
                                    <DataTemplate>
                                        <TextBox Text="{xceedGrid:CellEditorBinding}" MaxLength="4" CharacterCasing="Upper" BorderThickness="0"/>
                                    </DataTemplate>
                                </xceedGrid:CellEditor.EditTemplate>
                            </xceedGrid:CellEditor>
                        </xceedGrid:Column.CellEditor>
                    </xceedGrid:Column>
                    <xceedGrid:Column FieldName="Description.Current" Title="Descrizione" Width="*">
                        <xceedGrid:Column.CellEditor>
                            <xceedGrid:CellEditor>
                                <xceedGrid:CellEditor.EditTemplate>
                                    <DataTemplate>
                                        <TextBox Text="{xceedGrid:CellEditorBinding}" MaxLength="60" BorderThickness="0"/>
                                    </DataTemplate>
                                </xceedGrid:CellEditor.EditTemplate>
                            </xceedGrid:CellEditor>
                        </xceedGrid:Column.CellEditor>
                    </xceedGrid:Column>
                    <xceedGrid:Column FieldName="HasDecimals" Title="Decimali" Width="60">
                        <xceedGrid:Column.CellEditor>
                            <xceedGrid:CellEditor>
                                <xceedGrid:CellEditor.EditTemplate>
                                    <DataTemplate>
                                        <CheckBox IsChecked="{xceedGrid:CellEditorBinding}" BorderThickness="0"/>
                                    </DataTemplate>
                                </xceedGrid:CellEditor.EditTemplate>
                            </xceedGrid:CellEditor>
                        </xceedGrid:Column.CellEditor>
                    </xceedGrid:Column>
                </xceedGrid:DataGridControl.Columns>
                <xceedGrid:DataGridControl.View>
                    <xceedViews:TableView UseDefaultHeadersFooters="False" IsAlternatingRowStyleEnabled="True">
                        <xceedGrid:TableView.Footers>
                            <DataTemplate>
                                <xceedGrid:InsertionRow />
                            </DataTemplate>
                        </xceedGrid:TableView.Footers>
                        <xceedViews:TableView.Theme>
                            <xceedViews:AeroNormalColorTheme />
                        </xceedViews:TableView.Theme>
                        <xceedViews:TableView.FixedHeaders>
                            <DataTemplate>
                                <xceedGrid:HierarchicalGroupByControl xceedViews:TableView.CanScrollHorizontally="False" NoGroupContent="Trascinare una colonna qui per raggruppare" />
                            </DataTemplate>
                            <DataTemplate>
                                <xceedGrid:ColumnManagerRow />
                            </DataTemplate>
                        </xceedViews:TableView.FixedHeaders>
                    </xceedViews:TableView>
                </xceedGrid:DataGridControl.View>
            </xceedGrid:DataGridControl>
        </Grid>
    </UserControl>
     

    Any thought why I am not able to add new rows?

    Thanks

    Antonio

    Filed under: ,
  •  04-27-2009, 8:44 AM Post no. 20566 in reply to 20559

    Re: Xceed DataGrid: Insertion row doesn't add a row

    Hi,

    I found the reason why this is not working.

    The Currencies ObservableCollection to which the DataGridCollectionViewSource binds to, is a collection of domain objects implementing the IEditableObject interface.

    I don't know why but having that interface implemented stops the show, removing the implementation the InsertionRow works fine.

     Has anybody an idea why this behaviour?

     Thanks

    Antonio

    Filed under:
  •  04-28-2009, 1:33 AM Post no. 20585 in reply to 20566

    Re: Xceed DataGrid: Insertion row doesn't add a row

    Debugging a bit more, it seams when you are adding a new row to a collection that implements the IEditableObject interface, only the EndEdit method is called. Probably it is correct due to the fact that while adding you don't have anything to backup, I don't know if this has any implication internally to the grid.

    My EndEdit methods implementation is like this, it is not doing anything special:

            public void EndEdit()
            {
                //delete current values
                storedProperties = null;
            }
     

    Has anybody tested the grid binding to a collections of objects implementing the IEditableObject interface?

    Thanks

    Antonio

    Filed under:
  •  05-08-2009, 1:56 PM Post no. 20831 in reply to 20585

    Re: Xceed DataGrid: Insertion row doesn't add a row

    Hi Antonio,

    Please review the sample FlexibleBinding, located in the directory C:\Xceed Samples\Xceed DataGrid for WPF v3.1\CSharp\FlexibleBinding, that shows how to implement the IEditableObject to properly work with the Xceed DatagridControl.

     

     

     


    Xceed - Software Developer and Technical Support
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.