Custom check box column copy past issue

5 posts, 0 answers
  1. Amit Patel
    Amit Patel avatar
    71 posts
    Member since:
    Sep 2009

    Posted 30 May 2012 Link to this post

    Hello,
    I am trying to figure out how to get the copy past working on custom check box column.  Below is the code for it. I have to override the CanEdit method  so that it does not go in edit mode when user click on the cell, but I still want the copy past to work. I think internally your code might be checking on this method to determine when to fire PasteContent event.  Is there any work around?

    Thanks
    Amit
    public sealed class GridViewCheckBoxColumn : GridViewBoundColumnBase 
    {
     public override FrameworkElement CreateCellElement(GridViewCell cell, object dataItem) 
    {
        BindingTarget = CheckBox.IsCheckedProperty;
        var target = new CheckBox().SetTwoWayBinding(CheckBox.IsCheckedProperty, DataMemberBinding.Path.Path);
        target.IsEnabled = !cell.ParentOfType<RadGridView>().IsReadOnly && !IsReadOnly; 
        // initial state dataItem.GetType().GetProperty(DataMemberBinding.Path.Path + "Enabled").Do(p =>  target.SetOneWayBinding(CheckBox.IsEnabledProperty, p.Name));
        dataItem.GetType().GetProperty(DataMemberBinding.Path.Path + "Visible").Do(p => target.SetOneWayBinding(CheckBox.VisibilityProperty, p.Name));
        target.HorizontalAlignment = HorizontalAlignment.Center;
        target.VerticalAlignment = VerticalAlignment.Center; dataItem.GetType().GetProperty(DataMemberBinding.Path.Path + "ToolTip").Do(p => cell.SetOneWayBinding(ToolTipService.ToolTipProperty, p.Name));
        return target;
    }
        public override bool CanEdit(object item)
        {
            return false// never go into edit mode
        }
    }


  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 01 Jun 2012 Link to this post

    Hi,

     I have tested the described situation. The reason why the paste is not done is that is you have the column readonly. Please set the column to be editable and the pasting will be fine.

    Greetings,
    Didie
    the Telerik team

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

  3. Amit Patel
    Amit Patel avatar
    71 posts
    Member since:
    Sep 2009

    Posted 04 Jun 2012 Link to this post

    Didie,

    right, it does work, but then user can click around the check box and the cell will go in edit mode. Since there is nothing for user to do in editable cell. In fact, user would get confused if one clicks outside of a check box, and then cell goes in edit mode. I want the user to directly interact with checkbox and update the value. Is there way to keep the cell in not editable and still be able to paste the value?

    Thanks,
    Amit
  4. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 05 Jun 2012 Link to this post

    Hi Amit,

     You could have the column editable and subscribe for the BeginningEdit event of the RadGridView. When the column is about to goes into edit mode, you need to cancel the event. For example if the GridView is named "clubsGrid", then the code would look like so:

    private void clubsGrid_BeginningEdit(object sender, GridViewBeginningEditRoutedEventArgs e)
            {
                e.Cancel = true;
            }

     I hope this is helpful.

    Regards,
    Didie
    the Telerik team

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

  5. Amit Patel
    Amit Patel avatar
    71 posts
    Member since:
    Sep 2009

    Posted 05 Jun 2012 Link to this post

    Didie,
    That worked!  Thanks for solving the issue!

    Amit

Back to Top