User clicks on ESCAPRE on New Row

7 posts, 0 answers
  1. Ravi
    Ravi avatar
    104 posts
    Member since:
    Oct 2012

    Posted 17 May 2011 Link to this post

    Hi,

    I have implemented the New row on my hierarchical grid. it works perfect. however when the user clicks on the new row, and new appears and when the user press Escape ONCE, the row edit mode is reverted but still the row still remains. If the user again press Escape the row disappears.

    My requirement is, If its a new Row, if the user press once escape button, even if it had data or not, the new row should disappear and the grid should come to normal state.

    Please advice.
  2. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 17 May 2011 Link to this post

    Hi David,

    Would you please, share with us what kind of data source you are using to populate your RadGridView?

    Kind regards,
    Ivan Ivanov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. Ravi
    Ravi avatar
    104 posts
    Member since:
    Oct 2012

    Posted 17 May 2011 Link to this post

    I have model class. I populate the data into the model class and then assign the data to the datagrid by the ItemSource property.
  5. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 17 May 2011 Link to this post

    Hi David,

    What type of collection have you assigned to the ItemsSource property?

    Kind regards,
    Ivan Ivanov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Ravi
    Ravi avatar
    104 posts
    Member since:
    Oct 2012

    Posted 17 May 2011 Link to this post

    List<myClass>
  7. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 17 May 2011 Link to this post

    Hi David,

    You may try utilizing this approach:
    public MainPage()
    {
        InitializeComponent();
        clubsGrid.CellEditEnded += new EventHandler<GridViewCellEditEndedEventArgs>(clubsGrid_CellEditEnded);
    }
    void clubsGrid_CellEditEnded(object sender, GridViewCellEditEndedEventArgs e)
    {
        if (clubsGrid.ChildrenOfType<GridViewNewRow>().First().IsInEditMode)
            clubsGrid.ChildrenOfType<GridViewNewRow>().First().CancelEdit();
    }

    Please, inform us if this solution meets your requirements.

    Kind regards,
    Ivan Ivanov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  8. Ravi
    Ravi avatar
    104 posts
    Member since:
    Oct 2012

    Posted 17 May 2011 Link to this post

    Hi,

    Thanks for your valuable suggestion.

    I tried the below code and its working.

    else if (key == Key.Escape)
               {
                   commandsToExecute.Add(RadGridViewCommands.CancelRowEdit);
               }

    Inheriting from
    DefaultKeyboardCommandProvider

    Thanks,
Back to Top
DevCraft banner