PastingCellClipboardContent does not fire for Columns that are set as ReadOnly

6 posts, 0 answers
  1. Matthew
    Matthew avatar
    46 posts
    Member since:
    Aug 2011

    Posted 14 Nov 2011 Link to this post

    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?
  2. Matthew
    Matthew avatar
    46 posts
    Member since:
    Aug 2011

    Posted 16 Nov 2011 Link to this post

    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.
  3. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 17 Nov 2011 Link to this post

    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 >>

  4. Matthew
    Matthew avatar
    46 posts
    Member since:
    Aug 2011

    Posted 17 Nov 2011 Link to this post

    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.
  5. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 23 Nov 2011 Link to this post

    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 >>

  6. Matthew
    Matthew avatar
    46 posts
    Member since:
    Aug 2011

    Posted 23 Nov 2011 Link to this post

    Thanks Maya, I will try parsing through the Telerik.Windows.Controls.Clipboard.GetText(), this should satisfy my requirements.
Back to Top