Some questions about GridView edit mode

7 posts, 0 answers
  1. haochen
    haochen avatar
    13 posts
    Member since:
    Jun 2014

    Posted 06 Jan Link to this post

    Hi,

     I have some question about GridView edit mode.

    Question 1:

    In the GridView's PerpareCellForEdit event, I have some business code for verifying whether the current cell can be edited. If business cannot let the cell be edited, I used CancelEdit() function to exit edit mode, but the CancelEdit() function will fire CellEditEnded event. I have some code for DB communication in that event. Do you have some way the can leave edit mode but don't fire CellEditEnded event?

    Question 2:

    When we double clicked a cell, it will change to edit mode. If we click the other cells or other places, it will leaves edit mode, but if we click the next cell in the same row, the next cell will still in the edit mode and fired CellEditEnded event and PrepareCellForEdit event. I don't  want to click the next cell in the same row stay with in edit mode, I want to leave edit mode when click the next cell. Is there a way to achieve it?

     

    Than you

  2. haochen
    haochen avatar
    13 posts
    Member since:
    Jun 2014

    Posted 06 Jan Link to this post

    I find a way to resolved question 1.

    I changed PrepareCellForEdit event to BeginningEdit event, and set the e.Cancel = true.

    But in the PrepareCellForEdit event I try to set e.Cancel = true, is not working.

  3. UI for WPF is Visual Studio 2017 Ready
  4. haochen
    haochen avatar
    13 posts
    Member since:
    Jun 2014

    Posted 06 Jan Link to this post

    I have a new additional question:

    I want to change the EditTrigger to double click, not click current selected cells. Is there have a way to do this?

    Thank you

  5. haochen
    haochen avatar
    13 posts
    Member since:
    Jun 2014

    Posted 06 Jan in reply to haochen Link to this post

    Now the EditTrigger more like selected a cell twice to change the edit mode. 
  6. Stefan X1
    Admin
    Stefan X1 avatar
    521 posts

    Posted 08 Jan Link to this post

    Hi Haochen,

    Thank you for the detailed information.

    However, I would like to suggest you a slightly different approach for this scenario. Instead of using the editing events of RadGridView, I suggest you benefiting from the validation functionality that the control supports, as it is triggered before the editing one. I suggest you taking a look at the Validating section of RadGridView's online help. Shortly said, if the validation logic for determining whether a cell can be edited does not pass, the editing events would not be fired and the control will leave edit mode.

    As for the editing operation in general, you can take a look at the Updating an Entry help topic.

    Hope this helps.

    Best Regards,
    Stefan X1
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  7. haochen
    haochen avatar
    13 posts
    Member since:
    Jun 2014

    Posted 10 Jan in reply to Stefan X1 Link to this post

    Hi Stefan,

    Thank you for you reply.

    The validating function is awesome! I know how to do it.

    I read the “Updating an Entry” help. this document says F2 or double click can trigger edit mode. but I set EditTriggers = F2, the double click cannot change cell to edit mode. If I don't set EditTriggerts or set EditTriggers = Default,  When I click the cell twice very slowly, it still will change cell to edit mode.

  8. Stefan X1
    Admin
    Stefan X1 avatar
    521 posts

    Posted 13 Jan Link to this post

    Hello Haochen,

    You should be able to achieve this requirement by setting the EditTriggers property of the control to "None". Then you should subscribe to the MouseDoubleClick event of RadTreeListView and call the BeginEdit() method. You can take a look at the code snippet below.
    private void radTreeListView_MouseDoubleClick(object sender,
        MouseButtonEventArgs e)
    {
        this.radTreeListView.BeginEdit();
    }

    Can you please clarify whether this is the behavior of RadTreeListView you were trying to achieve?

    All the best,
    Stefan X1
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top
UI for WPF is Visual Studio 2017 Ready