Saving while editing

15 posts, 0 answers
  1. Thomas
    Thomas avatar
    34 posts
    Member since:
    Nov 2011

    Posted 23 Dec 2011 Link to this post

    Hello,

    If I insert a new row in a RadGridView, then start editing it, then click outside of that row, then click on my save button.
    The record go to the database.

    If I insert a new row in a RadGridView, then start editing it, then immediately without click on my save button clicking outside of the row .
    The records is not in the database.

    this is how the code associated with my save button goes:
                this.myRadGridView.EndEdit();
                this.myBindingSource.EndEdit();
                this.myDataEntities.SaveChanges();

    How could I correct this behaviour ?

    Thank you for your help.

    PS : I forgot to say I had the record through the BindingSource(this.myBindingSource.AddNew();)
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 26 Dec 2011 Link to this post

    Hi Thomas,

     As I understand your query, you would like to save the changed once you have done editing the row (when you click outside of the row).

    If this is the case, then you could save changes for your DataEntities when the RowEditEnded event  is fired.

    Is this what do you need?

    Kind regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Thomas
    Thomas avatar
    34 posts
    Member since:
    Nov 2011

    Posted 26 Dec 2011 Link to this post

    I have no 'RowEditEnded' event on myDataEntities(ObjectContext).

    But anyway, it's not what I want to do.

    Let's say I have my grid, and a custom 'Save' button, and a custom 'Insert' button.
    What I want:
    1. The user insert a row in the BindingSource (myBindingSource.AddNew());
    2. The row is added to the RadGridView.
    3. The user start editing
    4. The user writes some text
    5. The user clicks directly on his 'Save' button, and not anywhere else on the grid or the form.
    6. Somewhere after the clicks, I want the editing to end before I save the data to the database.
    7. I save the data.

    What is currently happning :
    1 to 5: same as above
    6. The data are saved.
    7.The editing end --> which means that the new data are not in the DB, but they appear in the grid as if the were in the DB, until the next 'refresh'.

    I thought that running methods myRadGridView.EndEdit(); and/or myBindingSource.EndEdit() somewhere between the click and the saving of the data would end the edit, but apparently, it doesn't, and the click happens before the end of the edition.
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 27 Dec 2011 Link to this post

    Hello,

    The RowEditEnded is an event of the RadGridView and it is raised when a row edit ends. 

     Thank you for providing more details. I am reading through your description step by step, but still I cannot understand how after you move the focus to the Save button, the editing does not end. Is the Save button outside of the GridView? 

    I do not understand those lines:

    "REQUIRED: 6. Somewhere after the clicks, I want the editing to end before I save the data to the database.
    WRONG:       6. The data are saved. "

    "REQUIRED: 7. I save the data. "
    WRONG:        7.The editing end --> which means that the new data are not in the DB, but they appear in the grid as if the were in the DB, until the next 'refresh'. " 

    Regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  6. Thomas
    Thomas avatar
    34 posts
    Member since:
    Nov 2011

    Posted 27 Dec 2011 Link to this post

    I don't really know how to be more clear about steps 6&7 but it seems you almost got it, when I click on my save button, the edit ends, BUT it ends after the button's click event and not before.
    I've have even tried to put 'this.Save_RadButton.Focus();' in the button's click method.

    Yes the button is outside of the GridView.

    (And I still don't see any 'RowEditEnded' event on my RadGridView, the only thing I see that look more or less like it is 'CellEndEdit', but anyway, what I would like to do is to force the editing to end, not cactch an event telling me that it has ended.)

  7. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 27 Dec 2011 Link to this post

    Hi,

     Could you please tell me what version of the RadControls do you use?

    Regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  8. Thomas
    Thomas avatar
    34 posts
    Member since:
    Nov 2011

    Posted 27 Dec 2011 Link to this post

    I was using 2011 Q3, I've just upgrade to 2011 Q3 SP1, which brings no change in this situation.
  9. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 28 Dec 2011 Link to this post

    Hi,

    The GridView has a RowEditEnded event, it would be strange if your GridView does not have it.
    Have you set a value for the ActionOnLostFocus proeprty of the GridView? By default its value is "CommitEdit". How does your project behave if you set its value to "None"?

    Greetings,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  10. Thomas
    Thomas avatar
    34 posts
    Member since:
    Nov 2011

    Posted 28 Dec 2011 Link to this post

    Sorry ! I just realised that we are in the Silverlight forum while I should have posted this in the WinForms forum. I don't know how I ended here ... I will re-post this in the WinForms forum.
  11. David
    David avatar
    15 posts
    Member since:
    Nov 2011

    Posted 18 Jan 2012 Link to this post

    Hello, I am facing the same problem, in this case the RadRibbonButton is inside the RadRibbonWindow/RadRibbonView/QuickAccessToolBar in OOB mode, current version is 2011.3.1309.1050.
    And yes, the RadGridView.ActionOnLostFocus is explicitly set.
    bests
  12. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 19 Jan 2012 Link to this post

    Hello,

    What is the value for the RadGridView.ActionOnLostFocus? Is it "None"?

     We were not able to get this same behaviour. Would it be possible for you to send us a small repro project to show us the case. That way we can be much more helpful.

    Kind regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  13. David
    David avatar
    15 posts
    Member since:
    Nov 2011

    Posted 19 Jan 2012 Link to this post

    Hello Didie, I'm instantiating the rgv programmatically like this:

    var rgv = new RadGridView
    {
     ValidatesOnDataErrors = GridViewValidationMode.None,
     IsFilteringAllowed = true,
     ShowGroupPanel = false,
     RowIndicatorVisibility = Visibility.Visible,
     IsReadOnly = false,
     CanUserFreezeColumns = true,
     EnableColumnVirtualization = true,
     EnableRowVirtualization = true,
     ActionOnLostFocus = ActionOnLostFocus.CommitEdit,
    };


  14. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 20 Jan 2012 Link to this post

    Hello,

     I was not able to get any problem with committing the data. Would you please describe in full details what "the same problem" is. Without a sample project to reproduce the issue I may not suggest you further.

    Regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  15. Thomas
    Thomas avatar
    34 posts
    Member since:
    Nov 2011

    Posted 20 Jan 2012 Link to this post

    I don't know if this can help you but when I posted  my own problem in the Winforms section, here's the answer I got in the end. I did not try temporary solution because I've been busy on other things that the related project these last weeks :

    Reply from Telerik starts here:

    (...) It seems that you have bind the RadGridView to IQueryable object. I added it to our public issue tracking system. It will be addressed in one of the next releases.
    In the meantime, you can handle the update issue by simply changing the current row in that way:

    protectedsealedoverridevoidBindingNavigator_SaveAction(objectsender)
    {
        try
        {
            GridViewRowInfo row = this.countriesRadGridView.CurrentRow;
            this.countriesRadGridView.CurrentRow = null;
            this.countriesRadGridView.CurrentRow = row;
            this.DataContext.SaveChanges();
            base.FireUpdateData();
        }
        catch(Exception Ex)
        {
            stringexMessage = Ex.Message;
            MessageBox.Show(exMessage);
        }
    }
  16. MiddleTommy
    MiddleTommy avatar
    163 posts
    Member since:
    Nov 2009

    Posted 20 Jan 2012 Link to this post

    I think I have had a similar problem. How I solved it as a work around is make your save button get focus on mouse over. This will force the grid to loose focus and commit the edit before you save. RadMenuItems automatically do this.

    pseudo
    public void MouseOverButton(object sender...)
    {
          var btn = sender as Button;
          btn.Focus();
    }
Back to Top
DevCraft banner