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

CellEditor loses focus immediately upon Edit

Sort Posts: Previous Next
  •  03-12-2009, 5:00 PM Post no. 19253

    CellEditor loses focus immediately upon Edit

    What I really need is a really good walkthrough of how to use a celleditor in a DataGrid bound to a database...

     

    But, at the moment, I have two immediate problems... Eternal gratefulness if anyone can help or point me in the right direction.

     

    I have a DataGrid populated with "Modules."  A "Module" can be assigned to a "Category" (but it is not required).  The DataGrid displays the Category to which a Module is assigned.  When I Edit the Module row, I want the user to be able to select from a combobox of Categories populated from a Database.

    Currently, if a Module has no Category, I can click on the empty cell, which will display the correctly populated combobox.  When I select a value fromt he ComboBox, the CB disappears (reverst to "View?") but there is no value present in the DataGrid row.

    The second issue is that, when a Module already has an assigned Category, the Category shows properly in the DataGrid view, but if I click on the cell in an attempt to edit it (i.e. display the combobox), the 0-index row becomes selected and no combobox is ever displayed.

    Any help at all... much much appreciated.  Thank you!

     

    CODE:

        <Grid Name="Grid1">



            <Grid.Resources>

                <xcdg:DataGridCollectionViewSource EditCommitted="dgcs_EditCommitted" x:Key="ID" Source="{Binding Source={x:Static Application.Current},Path=Modules}"/>

            </Grid.Resources>


            <xcdg:DataGridControl x:Name="CategoriesGrid" ItemsSource="{Binding Source={StaticResource ID}}">


                <xcdg:DataGridControl.Columns>

                    <xcdg:Column FieldName="ID" Title="ID" ReadOnly="True" Visible="False" IsMainColumn="True"></xcdg:Column>

                    <xcdg:Column FieldName="CatName" Title="Category Name">

                        <xcdg:Column.CellEditor>

                            <xcdg:CellEditor>

                                <xcdg:CellEditor.EditTemplate>

                                    <DataTemplate>

                                        <ComboBox BorderThickness="0" MinHeight="22" SelectedValue="{xcdg:CellEditorBinding}" ItemsSource="{Binding Source={x:Static Application.Current},Path=Categories}" SelectedValuePath="DisplayName" DisplayMemberPath="DisplayName" VerticalContentAlignment="Top" FocusVisualStyle="{x:Null}">

                                            <ComboBox.Resources>

                                                <Style TargetType="Popup">

                                                    <Setter Property="TextElement.Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}" />

                                                </Style>

                                            </ComboBox.Resources>

                                        </ComboBox>

                                    </DataTemplate>

                                </xcdg:CellEditor.EditTemplate>

                            </xcdg:CellEditor>

                        </xcdg:Column.CellEditor>

                    </xcdg:Column>

                    <xcdg:Column FieldName="DisplayName" Title="Module Name" />

                    <xcdg:Column FieldName="OrderVal" Title="Display Order" />

                    <xcdg:Column FieldName="CatOrder" Visible="False" />

                    <xcdg:Column FieldName="xtID" Title="Express Train ID" ReadOnly="True" />

                </xcdg:DataGridControl.Columns>

                <xcdg:DataGridControl.View>

                    <xcdg:TableView ColumnStretchMode="All" UseDefaultHeadersFooters="False">

                        <xcdg:TableView.FixedHeaders>

                            <DataTemplate>

                                <xcdg:HierarchicalGroupByControl xcdg:TableView.CanScrollHorizontally="False" />

                            </DataTemplate>

                            <DataTemplate>

                                <xcdg:ColumnManagerRow />

                            </DataTemplate>

                        </xcdg:TableView.FixedHeaders>

                    </xcdg:TableView>

                </xcdg:DataGridControl.View>

            </xcdg:DataGridControl>


        </Grid> 

  •  03-18-2009, 4:50 PM Post no. 19405 in reply to 19253

    Re: CellEditor loses focus immediately upon Edit

    Hi Jim,

    You may have a CellEditor on your column, but you are missing a "cell viewer" to display the value when the cell isn't being edited (and therefore the combobox isn't visible).

    For example:

      <xcdg:Column FieldName="CatName" Title="Category Name">

        <xcdg:Column.CellEditor>

          <!-- rest of your code -->

        </xcdg:Column.CellEditor>

        <xcdg:Column.CellContentTemplate>

          <DataTemplate>

            <TextBlock Text="{xcdg:CellEditorBinding}" />

          </DataTemplate>

        </xcdg:Column.CellContentTemplate>

      </xcdg:Column>


    This will solve the first issue you are describing, and may resolve the second as well but I haven't done a thorough test to try and reproduce your situation. Let me know if you still have problems after adding the cell viewer.

     


    ** Quick Tip: Clients with an active support subscription should be sending their questions by email if they wish to benefit from the faster response time. Thanks!


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