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

RadTreeNodeData and Category property

4 Answers 155 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Christian
Top achievements
Rank 1
Christian asked on 24 Jul 2008, 07:39 AM

Hi!

I am building a TreeView using the TreeNodeExpandMode.WebService expand mode.

When building the nodes in the WebService method, the Category property is missing in the RadTreeNodeData object. The property exists in the RadTreeNode, but not in the RadTreeNodeData.

Is this property missing for any particular reason? And is the any workaround for this issue?

Best Regards,
Christian

4 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 25 Jul 2008, 02:19 PM
Hi Christian,

You can use your own Custom class to send data from the Web Service to the RadTreeView. The only requirement for this class is that its properties should match those of the RadTreeNode object.

For example, if you had your CustomNodeData class with properties Text, Value and Category, they will be automatically set to the new Nodes added via this Web Service.

Another approach, however, would be to set an Attribute to the RadTreeNodeData object with the respective Category. Later, in the ClientNodePopulating event handler you can set this Attribute as the real Category of the Node.

Sincerely yours,
Simon
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Christian
Top achievements
Rank 1
answered on 28 Jul 2008, 07:15 AM
Hi Simon,

Thanks for your reply!

I tried making my own NodeData class, containing Text, Value, ExpandMode and Category properties. The Text, Value and ExpandMode properties are set correctly on the TreeNode. But the Category property is not set correctly and is null.

I also tried your second approach and saved the Category in the Attributes collection. I can retrieve this data in the ClientNodePopulating client side method, but the RadTreeNode client object dosen't have any set_category() method.

Any other ideas?

Best Regards,
Christian
0
Accepted
Simon
Telerik team
answered on 28 Jul 2008, 04:15 PM
Hi Christian,

Thank you for getting back to me.

Indeed, the Category was not set in this case. As for the client-side RadTreeNode object's set_category() function - it exists but it is not documented - something which we will fix right away.

As a workaround to the issue, I suggest you use the new client-side event of RadTreeView (in version Q2) - OnClientNodeDataBound, which fires for each Node that is bound via Web Service. It has the get_dataItem() function which returns an object with the same properties as the NodeData (in your case) object. You can use this event to set the category of each Node.

Finally, your Telerik points have been updated for the report.

Sincerely yours,
Simon
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Christian
Top achievements
Rank 1
answered on 29 Jul 2008, 01:56 PM
Hi Simon,

Thanks for your response. Your suggestion helped. I upgraded to Q2 and used the following JS code:

function

TreeView_NodeDataBound(sender, eventArgs)
{
    var node = eventArgs.get_node();
    var dataItem = eventArgs.get_dataItem();

    node.set_category(dataItem.Category);
}

Thanks for your help!
Christian

Tags
TreeView
Asked by
Christian
Top achievements
Rank 1
Answers by
Simon
Telerik team
Christian
Top achievements
Rank 1
Share this question
or