This is a migrated thread and some comments may be shown as answers.

Custom check box column copy past issue

4 Answers 77 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Amit Patel
Top achievements
Rank 1
Amit Patel asked on 30 May 2012, 07:15 PM
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
    }
}


4 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 01 Jun 2012, 09:21 AM
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 >>

0
Amit Patel
Top achievements
Rank 1
answered on 04 Jun 2012, 01:38 PM
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
0
Dimitrina
Telerik team
answered on 05 Jun 2012, 08:27 AM
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 >>

0
Amit Patel
Top achievements
Rank 1
answered on 05 Jun 2012, 01:55 PM
Didie,
That worked!  Thanks for solving the issue!

Amit

Tags
GridView
Asked by
Amit Patel
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Amit Patel
Top achievements
Rank 1
Share this question
or