Edit Triggers On The Cell Level

4 posts, 0 answers
  1. David
    David avatar
    13 posts
    Member since:
    May 2015

    Posted 15 Nov 2016 Link to this post

    Hi, 

    Is there a way to set edit triggers on the cell level? I need that in the same column, some of the cells will have a different edit trigger value from other cells (depends on a certain bushiness logic condition that can be implemented in a converter, for example).

  2. Yoan
    Admin
    Yoan avatar
    1214 posts

    Posted 17 Nov 2016 Link to this post

    Hello David,

    EditTriggers can be set only on Column or RadGridView level. However, you can mimic  this behaviour by handling the PreviewMouseDown event in this way:
    private void clubsGrid_PreviewMouseDown(object sender, MouseButtonEventArgs e)
           {
               var clickedElement = e.OriginalSource as FrameworkElement;
               var cell = clickedElement.ParentOfType<GridViewCell>();
               if (cell != null)
               {
                   var club = cell.ParentRow.Item as Club; //this is the data object
                   if (club.StadiumCapacity > 5)
                   {
                       clubsGrid.CurrentCellInfo = new GridViewCellInfo(club, cell.Column);
                       this.clubsGrid.BeginEdit();
                   }
                   
               }
           }

    In this way you will be able to enter in edit mode with a single click on items which StadiumCapacity is greater than 5 (this is the custom condition).

    I hope this will work for you.

    Regards,
    Yoan
    Telerik by Progress
    Telerik UI for WPF is ready for Visual Studio 2017 RC! Learn more.
  3. David
    David avatar
    13 posts
    Member since:
    May 2015

    Posted 20 Nov 2016 in reply to Yoan Link to this post

    Thanks. Actually I find this approach inappropriate to my specific needs, but I found another solution -

    1) The EditTrigger of the grid is always set to "CellClick".

    2) The visibility of the CellEditTemlpate is bounded to a converter, that returns "Visible" in case the cell should be editable and "Hidden" in case not. This gives the user an illusion that the cell is not in edit mode, even though it is.

  4. Yoan
    Admin
    Yoan avatar
    1214 posts

    Posted 23 Nov 2016 Link to this post

    Hi David,

    I am glad to hear that

    I will research the possibility of exposing an EditTriggers property of the GridViewCell. I will update this thread when the research is finished.

    Regards,
    Yoan
    Telerik by Progress
    Telerik UI for WPF is ready for Visual Studio 2017 RC! Learn more.
Back to Top