Problem with radDock and a new row in a radGridView

8 posts, 0 answers
  1. Pierre
    Pierre avatar
    6 posts
    Member since:
    Jan 2013

    Posted 09 Jan Link to this post

    Hi,

    I have this problem:

    In a Form with a RadDock, in this RadDock two ToolWindows with one button each and two DocumentWindows. In a DocumentWindow, a RadGridView.

    The RadGridView is with the event UserAddingRow:

    private void RadGridView1_UserAddingRow(object sender, Telerik.WinControls.UI.GridViewRowCancelEventArgs e)
     {
         if (e.Rows.Count() > 0 && e.Rows[0].Cells["Id"].Value == null)
         {
             e.Cancel = true;
             this.radGridView1.GridNavigator.Select(this.radGridView1.MasterView.TableAddNewRow, this.radGridView1.Columns["Id"]);
             this.radGridView1.BeginEdit();
         }
     }

     

    If you are editing a new row in the RadGridView with the value of "Id" null and you click on a button or in the tab of the other DocumentWindow, you don't stay in the new row. And the UserAddingRow event is fired many time.

    Why? How to edit the column "Id" of the new row if you validate by clicking in other control?

  2. Dess
    Admin
    Dess avatar
    2300 posts

    Posted 10 Jan Link to this post

    Hello, Pierre,   

    Thank you for writing.  

    I have logged it in our feedback portal. You can track its progress, subscribe for status changes and add your comments on the following link - feedback item.

    I have also updated your Telerik points.

    Currently, the possible solution that I can suggest is to RowValidating event instead:

    private void radGridView1_RowValidating(object sender, Telerik.WinControls.UI.RowValidatingEventArgs e)
       {
           if (e.Row is Telerik.WinControls.UI.GridViewNewRowInfo && e.Row.Cells["Id"].Value == null)
           {
               this.radGridView1.MasterView.TableAddNewRow.CancelAddNewRow();
               this.radGridView1.CurrentRow = this.radGridView1.MasterView.TableAddNewRow;
           }
       }

    I hope this information helps. Should you have further questions I would be glad to help.
     
    Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Pierre
    Pierre avatar
    6 posts
    Member since:
    Jan 2013

    Posted 10 Jan in reply to Dess Link to this post

    Thank you for your quick response, but I have the same problem with the event RowValidating. It is triggered several times as you can see in the attached GIF. And we do not stay in the new line.
    If we uncomment the last two lines of the code that follows, then we freeze the edition of the radgridview.

    private void radGridView1_RowValidating(object sender, Telerik.WinControls.UI.RowValidatingEventArgs e)
     {
         if (e.Row is Telerik.WinControls.UI.GridViewNewRowInfo && e.Row.Cells["Id"].Value == null)
         {
             Console.WriteLine("RowValidating");
             this.radGridView1.MasterView.TableAddNewRow.CancelAddNewRow();
             this.radGridView1.CurrentRow = this.radGridView1.MasterView.TableAddNewRow;
             //this.radGridView1.GridNavigator.Select(this.radGridView1.MasterView.TableAddNewRow, this.radGridView1.Columns["Id"]);              //this.radGridView1.BeginEdit();
         }
     }
      

  4. Dess
    Admin
    Dess avatar
    2300 posts

    Posted 10 Jan Link to this post

    Hello, Pierre,  

    Thank you for writing back. 

    I was able to replicate the multiple firing of the RowFormatting event. An alternative solution that I can suggest is to use the CellValidating event. Thus, you will be stuck in the cell once it is focused until you enter a valid value:
    private void radGridView1_CellValidating(object sender, Telerik.WinControls.UI.CellValidatingEventArgs e)
    {
        Console.WriteLine("CellValidating");
        if (e.Column.Name == "Id" && e.Value == null)
        {
            e.Cancel = true;
            if (e.Row is Telerik.WinControls.UI.GridViewNewRowInfo)
            {
                this.radGridView1.MasterView.TableAddNewRow.CancelAddNewRow();
            }
        }
    }

    I hope this information helps. If you have any additional questions, please let me know. 

     Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  5. Pierre
    Pierre avatar
    6 posts
    Member since:
    Jan 2013

    Posted 10 Jan in reply to Dess Link to this post

    I think you meant RowValidating instead of RowFormatting in your last post.
    For the CellValidating unfortunately it does the same thing, several calls to CellValidating when we go through the e.cancel and then the form is no longer accessible. You can see it in the .gif attached to this post.
    Do you think the fix will be quickly found because this way of using Telerik objects is necessary.
  6. Dess
    Admin
    Dess avatar
    2300 posts

    Posted 11 Jan Link to this post

    Hello, Pierre,  

    Thank you for writing back. 

    Yes, indeed I meant RowValidating event. As to the CellValidating event, it is fired each time you try to exit the cell. It is normal behavior. When the new row becomes current you can change the current column to "Id". Thus, you won't be able to exit the cell until a valid value is entered.

    I can't give you an exact timeframe when the issue will be addressed. You can track its progress, subscribe for status changes and add your comments on the following link: https://feedback.telerik.com/Project/154/Feedback/Details/240120-fix-radgridview-useraddingrow-is-fired-multiple-times-when-the-grid-is-inside

    We will do out best to introduce a fix as soon as possible.

    I hope this information helps. If you have any additional questions, please let me know. 

     Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  7. Pierre
    Pierre avatar
    6 posts
    Member since:
    Jan 2013

    Posted 11 Jan in reply to Dess Link to this post

    I don't think CellValidating work fine, because when you change the column in the new row from "name" to "Id" it fired one. But when you change the column in the new row from "Id" to "name" it fired twice and freeze the form.

    And when you change the column in the new row from "Id" to the button "Button1", it fired 4 times.


    I wait for the fix

  8. Dess
    Admin
    Dess avatar
    2300 posts

    Posted 12 Jan Link to this post

    Hello, Pierre,  

    Thank you for writing back. 

    After performing some tests, I was able to replicate the multiple firing of the CellValidating event. I have updated the feedback item with a note to include this case as well. Unfortunately, the issue is at a location that is too deep for any customization to have an effect on it. Currently, the possible solution that I can suggest is to cancel the CellValidating event without using the TableAddNewRow.CancelAddNewRow method. Thus, you will be stuck in the invalid cell. If you press Escape, the new row will be rejected. Indeed, the event may be fired multiple times, but you can keep the last cell that triggered the event and if the last value is identical. In this case, you won't notify the user a second time for the invalid input.

    We will do our best to introduce a fix as soon as possible.

    I hope this information helps. If you have any additional questions, please let me know. 

     Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top