Home Forums WPF controls Xceed DataGrid for WPF Cell update on LostFocus

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • Xceed Support
    Member
    Post count: 5658
    #22171 |

    Hi,

    In the documentation, it says that: At runtime, modifications made to the content of a cell can be committed when the focus leaves the cell, or discarded when the Escape key is pressed.

    I was wandering how to get the cell to update when the focus leaves, is this an property to set?

    Thanks in advance

    Imported from legacy forums. Posted by Simon (had 7340 views)

    User (Old forums)
    Member
    Post count: 23064

    This is the default behavior.

    Imported from legacy forums. Posted by Pascal (had 449 views)

    Xceed Support
    Member
    Post count: 5658

    Then that means there is a bug:

    I have a window with a Xceed Grid in this grid I have a CellEditor.TextBoxEditor and when I edit a existing value and click on a button in the window, the value is not updated.

    I have the same behavior when I have a Xceed grid in a tab item and I click on a different Tab item, the last cell that I changed the value is not updated.

    Is there a way to bypass this bug?

    Imported from legacy forums. Posted by Simon (had 446 views)

    Xceed Support
    Member
    Post count: 5658

    I made a Combo Box Cell Editor and to bypass the bug I used this:

    private void ComboBox_SelectionChanged( object sender, SelectionChangedEventArgs e )
    {
    if ( this.DataControl.CurrentItem == null )
    return;

    XceedDataRow row = this.DataControl.ItemContainerGenerator.ContainerFromItem( this.DataControl.CurrentItem ) as XceedDataRow;

    if ( row != null )
    row.EndEdit();
    }

    Should I use a similar function with the TextBox Cell Editor?

    Imported from legacy forums. Posted by Simon (had 410 views)

    User (Old forums)
    Member
    Post count: 23064

    I used the code you have posted for my ComboBox CellEditor and it works great 😉 . To use it with a textBox editor, you should link this code to the MouseLeave event. I’ve done this for a CheckBox cellEditor and it worked perfectly.

    Imported from legacy forums. Posted by Tanguy (had 548 views)

    User (Old forums)
    Member
    Post count: 23064

    We filed a bug for this.

    Imported from legacy forums. Posted by Pascal (had 423 views)

    Xceed Support
    Member
    Post count: 5658

    For a TextBox Cell Editor, I used LostKeyboardFocus and it works great.

    Imported from legacy forums. Posted by Simon (had 300 views)

    Xceed Support
    Member
    Post count: 5658

    Hi,

    Just wanted to drop-in on you concerning the issue where the row currently in edition does not leave edition mode when focus is moved elsewhere in the window/page.

    After analyzing this thoroughly, we arrived at the conclusion that it would be best fitted NOT to automatically “end” edition on the currently edited row when the DataGridControl loses focus.

    The 2 primary reasons behind this are:

    – We cannot assert what are the needs of each and every user. It might be possible that some people would like to perform actions in another control based on the row currently in edition ( I have no specific examples yet ).

    – Since we have a validation scheme on the DataGridControl, automatically ending an edition could result in a validation error (DataGridValidationException). Under such circumstances, the row in edition would remain in edition (and any actions performed on the data would be done on the “non-edited”, without any particular indications of the problem).

    However, we acknowledge that we need a solution that allows users that encountered the same problem as you have to overcome it easily.

    The fix we are proposing is to add functions on the DataGridControl class to allow easily ending edition ( or cancelling it), without the need to fetch the DataRow for the CurrentItem.

    This would allow ensuring that if you need “up-to-date” data, you’d have it easily. You’d also be able to easily detect that edition cannot be “ended” (DataGridValidationException) and decide whether or not you want to proceed with your action.

    If this solution is problematic for your needs, we’d like to hear from you. This is to make sure that we are not leaving specific needs “un-addressed”.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 629 views)

    User (Old forums)
    Member
    Post count: 23064

    This issue has been resolved in 1.2.7376.15420.
    It is available for download as of today from http://xceed.com/pages/TopMenu/Downloads/Trials.aspx

    Imported from legacy forums. Posted by Matt (had 514 views)

    User (Old forums)
    Member
    Post count: 23064

    still when I use LostKeyboardFocus with a textbox, the row is not commited, the value is the old one not the updated one, any idea?

    Imported from legacy forums. Posted by dalia (had 479 views)

    User (Old forums)
    Member
    Post count: 23064

    here is my celleditor once I edit the cell and get out the content changes to the old one
    <xcdg:CellEditor x:Key=”currencyEditor”>
    <xcdg:CellEditor.EditTemplate>
    <DataTemplate>
    <TextBox LostKeyboardFocus=”OnLostFocus_Commit” Text=”{Binding Path=., Mode=TwoWay}”/>
    </DataTemplate>
    </xcdg:CellEditor.EditTemplate>
    </xcdg:CellEditor>

    Imported from legacy forums. Posted by dalia (had 7996 views)

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.