Hi,
I'm using your WinForm treeview. I am populating the nodes using the NodesNeeded event. LazyMode is set to false and AutoCheckChildNodes is set to true.
Our data includes about 10 root notes. Some of the notes have over 30 000 nodes (many are parents with children). If we tick the root node, the tri state check box applies checks to all child nodes and ends up taking over a minute in some cases. If I disable AutoCheckChildNodes it doesn't appear to make any difference. If we just browse through the nodes and keep expanding different children, there is no issue, only when the status of a check box changes.
Ideally we would like to see the tri check status to persist but it doesn't need to update children items until they are open.
Thanks!
I'm using your WinForm treeview. I am populating the nodes using the NodesNeeded event. LazyMode is set to false and AutoCheckChildNodes is set to true.
Our data includes about 10 root notes. Some of the notes have over 30 000 nodes (many are parents with children). If we tick the root node, the tri state check box applies checks to all child nodes and ends up taking over a minute in some cases. If I disable AutoCheckChildNodes it doesn't appear to make any difference. If we just browse through the nodes and keep expanding different children, there is no issue, only when the status of a check box changes.
Ideally we would like to see the tri check status to persist but it doesn't need to update children items until they are open.
Thanks!
5 Answers, 1 is accepted
0
Hi Gerry,
Thank you for writing.
Usually when AutoCheckChildNodes is set to true the NodesNeeded event is fired when a parent node is checked, but it works really fast even with 30 000 nodes. However when you are adding nodes on the NodesNeeded event you do a few extra operations each time the event is fired which when combined with hierarchy may become slow. Additionally if you are making queries to the database that would make it even slower. I would recommend you to enable LazyMode in the RadTreeView if possible. If this approach is not available for you I would be glad to help once you provide me some additional information.
I hope this information is helpful. If you need any further assistance, please let me know.
Regards,
George
Telerik
Thank you for writing.
Usually when AutoCheckChildNodes is set to true the NodesNeeded event is fired when a parent node is checked, but it works really fast even with 30 000 nodes. However when you are adding nodes on the NodesNeeded event you do a few extra operations each time the event is fired which when combined with hierarchy may become slow. Additionally if you are making queries to the database that would make it even slower. I would recommend you to enable LazyMode in the RadTreeView if possible. If this approach is not available for you I would be glad to help once you provide me some additional information.
I hope this information is helpful. If you need any further assistance, please let me know.
Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Gerry
Top achievements
Rank 1
answered on 03 Sep 2013, 10:34 PM
Thank you for your answer.
I have tried using the TreeView in both lazy and non lazy mode. In my case I cannot use lazy mode because I need to know if there are nodes available to decide if an expand icon should show up. Here is the code involved. The objective is to show the file system structure. In my case my system has over 600 000 files and folders. When I check the C:\ check box it is instant but if I uncheck it takes 20-40 seconds. It appears it looks deeper in the file structure for some reason. The NodeFileInfo class is also shown in the code block.
I have tried using the TreeView in both lazy and non lazy mode. In my case I cannot use lazy mode because I need to know if there are nodes available to decide if an expand icon should show up. Here is the code involved. The objective is to show the file system structure. In my case my system has over 600 000 files and folders. When I check the C:\ check box it is instant but if I uncheck it takes 20-40 seconds. It appears it looks deeper in the file structure for some reason. The NodeFileInfo class is also shown in the code block.
private
void
PopulateRoot(IList<Telerik.WinControls.UI.RadTreeNode> nodes)
{
foreach
(DriveInfo DI
in
DriveInfo.GetDrives())
{
if
(!(DI.RootDirectory.ToString().StartsWith(
"A:"
) || DI.RootDirectory.ToString().StartsWith(
"B:"
)))
switch
(DI.DriveType)
{
case
DriveType.Fixed:
case
DriveType.Network:
case
DriveType.Removable:
Telerik.WinControls.UI.RadTreeNode TN =
new
Telerik.WinControls.UI.RadTreeNode(DI.RootDirectory.ToString());
NodeFileInfo NFI =
new
NodeFileInfo();
NFI.Path = DI.RootDirectory.ToString();
NFI.PathType =
"D"
;
TN.Tag = NFI;
nodes.Add(TN);
break
;
}
}
}
private
void
trvBackupSource_NodesNeeded(
object
sender, Telerik.WinControls.UI.NodesNeededEventArgs e)
{
if
(IgnoreNextNeedRequest)
{
IgnoreNextNeedRequest =
false
;
return
;
}
if
(e.Parent ==
null
)
{
this
.PopulateRoot(e.Nodes);
}
else
{
NodeFileInfo NFIParent = (NodeFileInfo)e.Parent.Tag;
if
(NFIParent.PathType.ToUpper() ==
"D"
)
{
// TODO: Won't load some folders due to user rights. Need to address this issue
try
{
foreach
(
string
Dir
in
Directory.GetDirectories(NFIParent.Path))
{
Telerik.WinControls.UI.RadTreeNode TN =
new
Telerik.WinControls.UI.RadTreeNode(Dir,
false
);
NodeFileInfo NFI =
new
NodeFileInfo();
NFI.Path = Dir;
NFI.PathType =
"D"
;
TN.Tag = NFI;
e.Nodes.Add(TN);
}
}
catch
{ }
try
{
foreach
(
string
F
in
Directory.GetFiles(NFIParent.Path))
{
Telerik.WinControls.UI.RadTreeNode TN =
new
Telerik.WinControls.UI.RadTreeNode(F,
false
);
NodeFileInfo NFI =
new
NodeFileInfo();
NFI.Path = F;
NFI.PathType =
"F"
;
TN.Tag = NFI;
e.Nodes.Add(TN);
}
}
catch
{ }
}
}
}
private
bool
IgnoreNextNeedRequest =
false
;
private
void
trvBackupSource_NodeCheckedChanged(
object
sender, Telerik.WinControls.UI.TreeNodeCheckedEventArgs e)
{
this
.btnBackupSourceSave.Enabled =
true
;
this
.btnBackupSourceUndo.Enabled =
true
;
IgnoreNextNeedRequest =
true
;
}
class
NodeFileInfo
{
private
string
_path =
""
;
public
string
Path
{
get
{
return
_path; }
set
{ _path = value; }
}
private
string
_pathtype =
""
;
public
string
PathType
{
get
{
return
_pathtype; }
set
{ _pathtype = value; }
}
}
0
Hello Gerry,
Thank you for writing back.
In such custom cases the best approach would be create your own logic which will handle everything according to your needs. I have prepared a sample project which contains a RadTreeView which represents the files structure of your computer. I have handled NodeExpandedChanged,NodeCheckedChanging and NodeExpandedChanging events. Files/Directories are only loaded when a node is expanded and when a parent node is checked only the visible children are checked/unchecked. Please refer to the attached zip file for more details.
Additionally in your case you can try using Begin/EndUpdate in your NodesNeeded event or stop directory traversal if when unchecking a node by raising some flag.
I hope this helps.
Regards,
George
Telerik
Thank you for writing back.
In such custom cases the best approach would be create your own logic which will handle everything according to your needs. I have prepared a sample project which contains a RadTreeView which represents the files structure of your computer. I have handled NodeExpandedChanged,NodeCheckedChanging and NodeExpandedChanging events. Files/Directories are only loaded when a node is expanded and when a parent node is checked only the visible children are checked/unchecked. Please refer to the attached zip file for more details.
Additionally in your case you can try using Begin/EndUpdate in your NodesNeeded event or stop directory traversal if when unchecking a node by raising some flag.
I hope this helps.
Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Gerry
Top achievements
Rank 1
answered on 01 Oct 2013, 10:51 PM
Thank you. I have been swamped so I will proceed to testing if this works for us (sounds like it will) and I'll provide feedback.
0
Hello Gerry,
Please, let us know if there is anything else.
Regards,
George
Telerik
Please, let us know if there is anything else.
Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>