Home Forums WPF controls Xceed DataGrid for WPF EndEdit –

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #26011 |

    Im having a nightmare getting things to work properly with the grid for editing.

    Basically I want to call EndEdit whenever a user clicks on another cell, at the moment its only firing when I the user presses Enter. Also Ideally when the grid loses focus however I’ll accept that as a limitation I can workaround if I can get the others basics sorted.

    I am beginning to regret the Xceed grid, Ive had to derive from Datarow and datagridcontrol just so I can add my own logic to persist on endedit.

    Imported from legacy forums. Posted by MattCheshire (had 3995 views)

    User (Old forums)
    Member
    Post count: 23064

    [quote]
    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. Programmatically, modifications are committed when the parent row’s EndEdit method is called, and discarded when the CancelEdit method is called. In either case, in order for the modifications to be committed, they must pass the validation process (see Validating Data).
    [/quote]

    The ONLY way I can get the modification commited (i.e the end edit event to fire on datarow), is when I press Return.???

    Imported from legacy forums. Posted by MattCheshire (had 756 views)

    User (Old forums)
    Member
    Post count: 23064

    [quote]
    modifications made to the content of a cell can be committed when the focus leaves the cell
    [/quote]

    Should that not read when the focus leaves the row? I cant get it to commit when I click on the next cell.

    Imported from legacy forums. Posted by MattCheshire (had 657 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Matt,

    When designing the DataGrid for WPF, we have decided not to add any “persistence” logic due to the fact that different clients might want to persist modified/added data on to their database/storage at different moments in their application lifetime.

    We understand that overriding the DataRow/DataGridControl might look like “overkill” to do such ‘simple’ tasks. We took good notes of the comments about the lack of CLR events to easily connect to the DataGridControl`s actions in order to build application logic around the DataGridControl. We did not include such events from the start because we wanted to make sure not to bring forth in our WPF components some development patterns that might solely belong in WinForms ( when we initially released the DataGrid for WPF, WPF itself was not ‘publicly’ one month old yet and we lacked any frame of reference or design guidelines ).

    We are listening to our users and it is in our intentions to correct these shortcomings in future releases.

    Concerning the committing of values. At the moment, values are committed to the data item only when the row leaves edition (either by pressing Return, selecting another row, or by explicitly calling Row.EndEdit() or DataGridControl.EndEdit() ). It was a design decision not to end edition when the DataGridControl loses focus ( once again, the need might vary from a user to the other ).

    Some people asked for a way to change the “commit” mode of edited values to the data item so that changes are committed back when cells (instead of Rows) leaves edition. Once again, we noted this and are planning to address this issue in an upcoming version.

    Finally, I have forwarded your comment about the mistake in the documentation. It should be corrected in the next version of the documentation (thank you for reporting this).

    I hope this helped a little bit.

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

    User (Old forums)
    Member
    Post count: 23064

    Our team also found it a bit odd that clicking a button outside of the grid does not fire EndEdit. The result was a crash.

    What was the reason the default styles do not, for example, have LostFocus event setup to fire EndEdit?

    Imported from legacy forums. Posted by Jack (had 1033 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Jack,

       The main reason why there is no default EndEdit() behavior for the LostFocus is because there are too many different scenarios from too many different users.

       The recommended usage would be to ensure to call DataGridControl.EndEdit()  in the button click handler before proceeding with you code.

      

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

    User (Old forums)
    Member
    Post count: 23064

    Is there another solution to this? If we have X controls we are going to need to place the end edit code into each X controls, which is …. silly to say the least.

    I tried to create a style for the DataRow which fires an event on LostFocus… the problem is the row loses focus when one of its cells enters edit more – which means you can’t edit a cell because it immediately cancels edit!! Catch 22.

    Any work arounds to this? Basically when a row loses focus we want to trigger an event which causes edits to be commited and then we can call some of our own logic to validate the item the row is bound to. 

    Imported from legacy forums. Posted by Jack (had 943 views)

    User (Old forums)
    Member
    Post count: 23064

    Hello,

     

    I have had the same problem along with 1 or 2 others here.  There is really no event that is fired when you leave the Grid.  (Really wish a event was made for thsi scenario)

    This is what I do to take care of that event. 

    (I make no claims that this is the best way to do things but it does seem to work when you leave the Grid.  (Unless you click the X to close the program.))

    If there is a better way….I am all ears (err eyes).

     

    private void dataGridControl_Site_ID_FocusableChanged(object sender, DependencyPropertyChangedEventArgs e)

    {

    Save_Site_ID_Data_To_Database();

    }

     

    private void dataGridControl_Site_ID_GotFocus(object sender, RoutedEventArgs e)

    {

    Save_Site_ID_Data_To_Database();

    }

     

    private void dataGridControl_Site_ID_IsKeyboardFocusWithinChanged(object sender, DependencyPropertyChangedEventArgs e)

    {

    // this method makes sure your changes are saved when you leave the DataGrid (for some reason the

    // data grid doesn’t fire the LostFocus event when a user leaves the DataGrid….very annoying. This  event seems

    // to work fairly well. Its called a like 6 times or so for some reason when it is fired.

     

    if (dataGridControl_Site_ID.IsFocused == false)

    {

    i_static++;  // ignore this—using it for testing

    dataGridControl_Site_ID.EndEdit();

    }

    }

     

     

    private void dataGridControl_Site_ID_LostFocus(object sender, RoutedEventArgs e)

    {

     

    Save_Site_ID_Data_To_Database();

     

    }

     

     

    private void dataGridControl_Site_ID_PropertyChanged(object sender, PropertyChangedEventArgs e)

    {

    Save_Site_ID_Data_To_Database();

    }

     

    private void dataGridControl_Site_ID_TargetUpdated(object sender, DataTransferEventArgs e)

    {

    Save_Site_ID_Data_To_Database();

    }

     

     

    Imported from legacy forums. Posted by David (had 1013 views)

    User (Old forums)
    Member
    Post count: 23064

    Please note you will probably have to add additional code if you have childrows that you wish to edit.

    Imported from legacy forums. Posted by David (had 2012 views)

    User (Old forums)
    Member
    Post count: 23064

    What is the intention of commiting the edited values only if the row changed???

     I really need to commit the value directly, as soons as the grid shows the new value I want my DataSource to be updated, because I have to recalculate other values of the row…

     
     So… What to do? Any ideas?

    Imported from legacy forums. Posted by Christian (had 740 views)

    Xceed Support
    Member
    Post count: 5658

    Version 2.1 addresses this issue and many more relating to the edit process.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 703 views)

    User (Old forums)
    Member
    Post count: 23064

    When is version 2.1 due out?

    Imported from legacy forums. Posted by justin (had 627 views)

    User (Old forums)
    Member
    Post count: 23064

    They say Summer-2008

    Imported from legacy forums. Posted by Abdullah (had 1623 views)

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