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