This code helps to scan(enumerate) nodes in the nested grids or mixed (trees and/or nested grids):
[c#]
private void ScanNodes(FlyGrid flyGrid)
{
//initial call - scan a root port
ScanNodesFromPort(flyGrid.ActiveRootPort, 0);
}
private void ScanNodesFromPort(FlyGridViewPort port, int indent)
{
foreach(NodeBase node in port.Rows.Items)
{
EnumerateCells(node, port.Columns, indent);
if (node.HasChildren)
{
NestedGridNode nested = node as NestedGridNode;
if (nested != null)
{
nested.Expanded = true;//it it necessary to get nested port
ScanNodesFromPort(nested.NestedInternal, indent+1);
}
else
ScanNodesFromItems(node.Items, port.Columns, indent+1);
}
}
}
private void ScanNodesFromItems(NodeCollection nodes, Columns columns, int indent)
{
foreach(NodeBase node in nodes)
{
EnumerateCells(node, columns, indent);
if (node.HasChildren)
{
NestedGridNode nested = node as NestedGridNode;
if (nested != null)
{
nested.Expanded = true;//it it necessary to get nested port
ScanNodesFromPort(nested.NestedInternal, indent+1);
}
else
ScanNodesFromItems(node.Items, columns, indent+1);
}
}
}
private void EnumerateCells(NodeBase node, Columns cols, int indent)
{
foreach(Column col in cols.VisibleColumns)
{
System.Diagnostics.Debug.WriteLine(GetIndentString(indent) + node[col].ToString());
}
}
private string GetIndentString(int indent)
{
return new string(' ', 2*indent);
}