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

On Demand Page Method check status lost

2 Answers 42 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Kai-Uwe
Top achievements
Rank 1
Kai-Uwe asked on 21 Jul 2010, 09:23 AM
Hi,

I have a tree view:

<

 

telerik:RadTreeView ID="RadTreeView1" runat="server" CheckBoxes="true"

 

 

 

CheckChildNodes="true" TriStateCheckBoxes="true" Skin="Outlook" ShowLineImages="false"

 

 

 

Style="margin-bottom: 10px">

 

 

 

</telerik:RadTreeView>

 

 



And I set the following properties to support load on demand:

radTreeView.WebServiceSettings.Path =

"~/zz_Portal/KdsDimensionLoader.aspx";

 

radTreeView.WebServiceSettings.Method =

 

"GetKdsDimElements";

 

node.ExpandMode =

 

TreeNodeExpandMode.WebService;

 

 


When I check a checkbox and then expand the node for the first time the parent will loose the checked status and the children are unchecked.
Not the expected behaviour.

In the web method it WOULB be very easy to implement the expected behaviour if we could use a proper RadTreeNode object.
But in the samples RadTreeNodeData is used and this object has not the Checked property.

So, how can I use Web Methods for on demand loading and keeping the checked status of the parent and have all children checked as well after adding them to the parent?

Thanks for any reply.

[

WebMethod]

 

 

 

public static RadTreeNodeData[] GetKdsDimElements(RadTreeNodeData node)

 

{

 

 

List<RadTreeNodeData> result = new List<RadTreeNodeData>();

 

 

 

DataRow kdsDimSlicer = MDXSlicers.FindSlicerById("11");

 

 

 

MetaData metaData1 = (MetaData)HttpContext.Current.Session[SessionVariables.MetaData.ToString()];

 

 

 

if (metaData1 != null)

 

{

 

 

string dimName = (string)kdsDimSlicer[MDXSlicers.DIMENSION];

 

 

 

string hierarchyName = (string)kdsDimSlicer[MDXSlicers.HIERARCHY];

 

 

 

DataTable table = metaData1.GetMembers(dimName, hierarchyName);

 

 

 

DataRow[] rows = table.Select("ParentUniqueName = '" + node.Value.Replace("'", "''") + "'");

 

 

 

foreach (DataRow row in rows)

 

{

 

 

RadTreeNodeData childNode = new RadTreeNodeData();

 

childNode.Text = row[

 

"Name"].ToString();

 

childNode.Value = row[

 

"UniqueName"].ToString();

 

 

 

DataRow[] checkChilds = table.Select("ParentUniqueName = '" + childNode.Value.Replace("'", "''") + "'");

 

 

 

if (checkChilds.Length > 0)

 

{

childNode.ExpandMode =

 

TreeNodeExpandMode.WebService;

 

}

result.Add(childNode);

}

}

 

 

return result.ToArray();

 

}

 


2 Answers, 1 is accepted

Sort by
0
Kai-Uwe
Top achievements
Rank 1
answered on 21 Jul 2010, 12:21 PM
Hi,

the answer is described here:

Inherit the the Checked state of the parent Node when loading Nodes on demand

and

Setting additional properties to the node in the Web Service 

I really have no idea why it is necessary to add this javascript manually.
Why are these both functions not added automatically when using checkboxes and on demand load?????????????????????
0
Nikolay Tsenkov
Telerik team
answered on 23 Jul 2010, 03:53 PM
Hello Kai-Uwe Baryga,

This is caused by the fact that you load on demand something that already has state. The checking can not be replayed on the client and having TriStateCheckBoxes="true" causes the root node to become in:
1. unchecked state (if all added nodes are not checked);
2. Indetermine state (if there are both checked and uchecked nodes).

Imagine the following situation:
1. the client requests nodes as children of already existing node;
2. if the CheckedChildNodes property worked as you expect it to, he will receive nodes with uncertain state (if the root node has been checked - they are all going to become checked and their previous state would be lost).
Therefore, if one want's the state of the requested nodes => he can not use the client behavior of CheckChildNodes.

That's why we try to give all the power to the client, instead restraining it with lots of default behavior. And now you are able to go with both scenarios.

Hope this explains it for you!
And if you experience any further difficulties, feel free to post your problems, we will be happy to help!


Regards,
Nikolay Tsenkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
TreeView
Asked by
Kai-Uwe
Top achievements
Rank 1
Answers by
Kai-Uwe
Top achievements
Rank 1
Nikolay Tsenkov
Telerik team
Share this question
or