Nodes lose value property after Databind

4 posts, 0 answers
  1. Paul Robertson
    Paul Robertson avatar
    78 posts
    Member since:
    May 2010

    Posted 21 Dec 2012 Link to this post

    Hi there

    I have a server-side button handler to make changes to the database from which the RadTreeView is populated. However, after calling Databind on the tree object to reflect the changes, the node objects for the tree all lose their Value property, which is a bit of a difficulty as I need to make use of that Value in the client-side processing immediately after the postback. Is this behaviour by design, and if so, how can I refresh the property in question, to populate the Values for each node after the databind?

    Thanks if you can help.


  2. Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 22 Dec 2012 Link to this post

    Hello Paul,

    How are you binding the RadTreeView? Are you using a DataSource control or just setting the DataSource property?
  3. DevCraft R3 2016 release webinar banner
  4. Paul Robertson
    Paul Robertson avatar
    78 posts
    Member since:
    May 2010

    Posted 28 Dec 2012 Link to this post

    Hi there

    The life cycle for the code relevant to the problem is as follows:

    1. In the initial server side Load handler, regardless of postback or not, an instance of a custom Hierarchical datasource object is created, and used to configure the Datasource property for a databind.

         cdsPubCommentDataSource = New CommentDataSource(1)
         radCommentTreeView1.DataSource = cdsPubCommentDataSource
         radCommentTreeView1.DataFieldID = "ID"
         radCommentTreeView1.DataFieldParentID = "ParentID"
         radCommentTreeView1.DataTextField = "Content"

    2. At the client, the treeview is populated correctly, and each node of the treeview can be seen to be represented as its own client-side Javascript object with a Value attribute with corresponding 'identity' value.

    3. The user clicks on a button within the template of a node to run some client-side status processing which finally triggers a server-side button handler postback.

    4. In the server-side click handler that modifies the underlying database, the server-side treeview node objects each have a correctly populated Value property, until the moment at which the databind method is called:


    at which point the content of each node is refreshed to correctly reflect the database changes, but the Value property is now empty (showing as an empty string "" during debugging), in all subsequent server-side processing ...

    5. As the client is processing the response from the postback, the attempt to run findNodeByValue is unsuccessful, because each client-side node object is missing its 'value' attribute, as to be expected given the disappearance of the corresponding server-side Value (in step 4.)

         var node = tree.findNodeByValue(value);
    returns 'null', as although a new client-side object exists for the node, it is lacking a 'value' attribute, and so the identity stored in the value attribute cannot be found.

    Could anybody point me in the right direction for why this might be happening? Thanks very much!

  5. Paul Robertson
    Paul Robertson avatar
    78 posts
    Member since:
    May 2010

    Posted 02 Jan 2013 Link to this post

    I think the answer to this problem is my misunderstanding of the Value property, which apparently is not natively populated at any stage in the radTreeView life cycle. Please correct me if I am wrong in my conclusion, but it seems that if the Value property is to be used client-side, it must be explicitly populated by assigning a string value on a node-specific basis to [mynode].Value during the server-side DataBound handler. This is the only way I can find to ensure that the Javascript tree object used by the client-side findNodeByValue function contains the required 'value' attribute - i.e., it is best to use this 'value' in the same way as a custom attribute, albeit one for which Telerik have provided a dedicated search function in the client-side API.

Back to Top