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

Issue with Spaces appended to data Copied value in clipboard

1 Answer 38 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Shiva
Top achievements
Rank 1
Shiva asked on 14 Jun 2013, 03:53 AM
Hi,
I am new to Rad grid controls and am facing an issue with Copy functionality of the telerik:RadTreeListView control in silverlight application. I am binding a collection of object to the RadTreeListView by setting the Itemdatasource property to the collection.
The treeListView is visible and works fine.Then when i select some cells and copy the content, they seem to be copied correctly.

I have set some context menu and when the user clicks the context menu, i navigate the user to the screen and the user is allowed to do some operations like create, edit,search etc. These are in another Xaml file.

Now once the user finishes the operation and comes back to the original page containing the RadTreeListView control, i rebind the object collection to the treeviewList ( same code as the first bind).

When the user now tries to select a cell and copy its content, there are lots of spaces added (towards the end) with the content of the selected cell.

The various properties that are set are as below:
<telerik:RadTreeListView x:Name="TreeViewList" AutoGenerateColumns="False" IsReadOnly="True" telerik:Clipboard.IsEnabled="True" SelectionMode="Extended" ClipboardCopyMode="Default" SelectionUnit="FullRow" telerik:StyleManager.Theme="Office_Blue" RowStyleSelector="{StaticResource RowStyleSelector}" SelectedCellsChanged="TreeViewList_SelectedCellsChanged" CopyingCellClipboardContent="TreeViewList_CopyingCellClipboardContent" />

A brief snippet of my TreeViewList_CopyingCellClipboardContent is as below:

  private void TreeViewList_CopyingCellClipboardContent(object sender, Telerik.Windows.Controls.GridViewCellClipboardEventArgs e)
        {
            if (e.Value != null)
            {
                   switch (TreeViewList.CurrentCellInfo.Column.Header.ToString())
                        {
                            case "Demo":
                                switch (((BusinessObject) e.Value).Property1)
                                {
                                    case 1:
                                        e.Value = ((BusinessObject) e.Value).Property2;
                                        break;
                                    case 2:
                                        e.Value = ((BusinessObject) e.Value).Property3;
                                        break;                                  
                                }
                            default:
                                break;
                        }
                    }
                    else
                    {
                        e.Value = null;
                        e.Cancel = true;
                    }

               
        }


When i check the value of content in TreeViewList_CopyingCellClipboardContent that is copied to clipboard (e.Value), i do not see any space in the object and the content copied in e.Value.

However, when i paste the copied item to a notepad, i see lots of additional spaces being added towards the end.
for example, if the cell contains 123 and i copy this cell and paste it in notepad i get 123             (some 15-20 characters of space after the 123).

The thing that is weird is that it happens only when i am binding the collection the second time ( after calling another xaml page and allowing the user to do some operation). The first time when the TreeListView is loaded and i copy the cell value, there is no spaces that gets appended to the copied value.

Best Regards,
Shiva

Update:
When i checked the copied data in SQl server, i see that lots of non printable Ascii characters are getting added. Some of the Ascii 
that gets added are 9 (Horizontal tab),13 (Carriage return),10(New line) and these constitute the additional spaces that are not visible in UI.
The sample sql is 
DECLARE @nstring nvarchar(255)='22048547
'
DECLARE @Result varchar(255)
SET @Result = ''

DECLARE @nchar nvarchar(1)
DECLARE @position int

SET @position = 1
WHILE @position <= LEN(@nstring)
BEGIN
SET @nchar = SUBSTRING(@nstring, @position, 1)
Select ASCII(@nchar) [ASCII value],@nchar [CharValue];
SET @position = @position + 1
END

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 19 Jun 2013, 11:07 AM
Hello,

I have tested copying the data for an entire row and the data for a single cell. At the end of the copied text there is only "10 13" values added. Actually the 1013 pair of characters is the signal for the end of a line and beginning of another one.

Would you please confirm whether you test with the latest version - Q2 2013? I have run the test SQL query on the text I copied from this online demo and at the end of the copied value there were only one '10' and one '13' value. Would you please try to reproduce it with text copied from that demo?

Regards,
Didie
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
TreeListView
Asked by
Shiva
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or