Web service binding issue with the "id" attribute

4 posts, 0 answers
  1. Tony
    Tony avatar
    7 posts
    Member since:
    Oct 2010

    Posted 05 Jul 2012 Link to this post

    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"]);
  2. Plamen
    Admin
    Plamen avatar
    2730 posts

    Posted 09 Jul 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tony
    Tony avatar
    7 posts
    Member since:
    Oct 2010

    Posted 09 Jul 2012 Link to this post

    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.
  5. Tony
    Tony avatar
    7 posts
    Member since:
    Oct 2010

    Posted 11 Jul 2012 Link to this post

    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.
Back to Top