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

PastingCellClipboardContent does not fire for Columns that are set as ReadOnly

5 Answers 52 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Matthew
Top achievements
Rank 1
Matthew asked on 14 Nov 2011, 07:37 PM
I have a radGrid with multiple columns, one of which is a CheckBoxColumn called "Adjustment".

If the Adjustment field for a row in the Grid is False (unchecked), then another column named "Rate" is set to be ReadOnly.  THis is done in the XAML file using a custom converter...

<UserControl.Resources>
        <converter:InvertBooleanConverter x:Key="InvertBooleanConverter" />
</UserControl.Resources>

...

<telerik:GridViewDataColumn Header="Rate" DataMemberBinding="{Binding Rate, Mode=TwoWay, ValidatesOnExceptions=True, StringFormat=\{0:c\}}" IsReadOnlyBinding="{Binding Adjustment, Converter={StaticResource InvertBooleanConverter}}" />

This is working perfectly.

However, if the Rate column is ReadOnly (Adjustment is False) the PastingCellClipboardContent Event does not fire for the Rate column.

I still need to paste the Rate value in from the Excel data which is in the clipboard (for example $34.50), but it is bypassing this field if the Cell is ReadOnly.  It is instead setting the field to $0.00.

Couldn't this event still fire even if the field is ReadOnly in order to initialize the field with a default value, or is there some other way I can have it populated into the field, or even another way to set the field to ReadOnly after it has been setup with the default value?

5 Answers, 1 is accepted

Sort by
0
Matthew
Top achievements
Rank 1
answered on 16 Nov 2011, 06:06 PM
Can I somehow get to the RadComboBox object in the GridViewComboBoxColumn from the GridViewCellClipboardEventArgs?

It would be nice if in the PastingCellClipboardContent Event I could do something like...

((RadComboBox)e.Cell.Cell).IsReadOnly == true;

This way I could populate the value into the field, and then set it to ReadOnly, as opposed to having to specify the ReadOnly criteria in the XAML file and have it bypass updating the field because it's ReadOnly.
0
Maya
Telerik team
answered on 17 Nov 2011, 04:07 PM
Hi Matthew,

You can try to set the value of the property directly through the underlying data item. For example:

private void clubsGrid_PastingCellClipboardContent(object sender, GridViewCellClipboardEventArgs e)
        {
            (e.Cell.Item as Club).Name = "NewName";
        }

Thus no matter if the column is read only or not, the value of the property will be updated.
 

Greetings,
Maya
the Telerik team

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

0
Matthew
Top achievements
Rank 1
answered on 17 Nov 2011, 05:27 PM
Hi Maya,

I understand how to set the properties for the underlying object - however, since the PastingCellClipboardContent Event does not fire for the field which is set as ReadOnly, I am unable to get the Value that is being pasted in from Excel.

For example, if the object has 3 fields (Name, Adjustment, Rate).  If Adjustment is TRUE, the PastingCellClipboardContent Event fires for each Cell in the Row that is being pasted in.

However, if Adjustment is FALSE, the PastingcelClipboardContent Event fires only for Name and Adjustment, then skips down to the next Row being pasted in.

Since the event does not fire for the Rate field in the 2nd example, I am unable to determine what the value is in order to set the underlying property to.
0
Maya
Telerik team
answered on 23 Nov 2011, 08:13 AM
Hi Matthew,

You can try to get the whole copied text through Telerik.Windows.Controls.Clipboard.GetText (), parse it and set the required value to the corresponding property (as illustrated above).

Kind regards,
Maya
the Telerik team

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

0
Matthew
Top achievements
Rank 1
answered on 23 Nov 2011, 05:08 PM
Thanks Maya, I will try parsing through the Telerik.Windows.Controls.Clipboard.GetText(), this should satisfy my requirements.
Tags
GridView
Asked by
Matthew
Top achievements
Rank 1
Answers by
Matthew
Top achievements
Rank 1
Maya
Telerik team
Share this question
or