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

Web service binding issue with the "id" attribute

3 Answers 45 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Tony
Top achievements
Rank 1
Tony asked on 05 Jul 2012, 10:28 AM
Hi,
I'm trying to implement drag & drop from ListView to TreeView. I need to assign a custom value on the "id" attribute so it can be used in ListView's DestinationHtmlElement in RadListViewItemDragDropEvent. If I bind the tree nodes on the Server-Side with RadTreeNode type, everything works fine. But if I use Web Service with RadTreeNodeData type, the DestinationHtmlElement is empty. Do I need to do something different with the web service?

// Server Side with RadTreeNode type works fine 
var node = new RadTreeNode();  
node.Attributes.Add("id", "folder_" + dtrReader["folderID"]);  
  
// Web Service with RadTreeNodeData type and the DestinationHtmlElement is empty
var node = new RadTreeNodeData();  
node.Attributes.Add("id", "folder_" + dtrReader["folderID"]);

3 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 09 Jul 2012, 12:01 PM
Hello Tony,

 
The idea of adding "ids" as custom attributes not recommended because custom attribute's name should not be an HTML reserved word. Please see this article for more information.

In your case you we recommend using "span" as an HtmlElement and then check if it's class is ".rtIn".

Hope this will be helpful.

Regards,
Plamen Zdravkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Tony
Top achievements
Rank 1
answered on 09 Jul 2012, 02:13 PM
Hello Plamen,

Thanks for the info. Actually, I need to drop a ListView item onto a TreeNode. The e.DestinationHtmlElement property only returns the id value of the destination HtmlElement, that's why I can only use the id attribute for my custom value.

protected void ListView1_ItemDrop(object sender, RadListViewItemDragDropEventArgs e) 
{
 if (e.DestinationHtmlElement.Contains("folder")) // any TreeNode created with Web Service returns empty,
but works fine with Server Side
    
   }
}
Is there a workaround using the Web Service or I must use the Server Side method instead? I hope I don't have to give up the Web Service because it's much faster and more efficient for my application.
0
Tony
Top achievements
Rank 1
answered on 12 Jul 2012, 01:55 AM
Hi,
I found out the TreeView needs to postback in order to work. The DestinationHtmlElement in RadListViewItemDragDropEventArgs shows my custom id after I made a postback by NodeClick or postback the UpdatePanel that contains the TreeView. I thought the commitChanges() suppose to do the update on the server right after the node got expanded,  seems like it didn't update the attributes or the newly expanded nodes were not registered on the server at all. I've tried calling  commitChanges() after the expand() and also from OnClientNodePopulated, non of them works. Anyways, here's some reference for anyone who needs to implement drop & drop from RadListView / RadGrid to TreeView populated with web service.
Tags
TreeView
Asked by
Tony
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Tony
Top achievements
Rank 1
Share this question
or