Friday, March 30, 2012

load CatalogItem array in treeview

Hi,

i would like to load my array 'items' in a treeview

CatalogItem[] items = rs.ListChildren("/", true);

is there anyway that automatically does the layout or do i have to check what the type is of everey object so I can indent correctly.

thanks
I'm really looking for this one :).

I'm trying to do it manually but I can't find a way to get the reports in the right structure. I'll show what I want to accomplish and how I am trying it now:

WANTED LIST:
+ Adventureworks
- Company Sales
- Employee Sales Summary
+ Subfolder
- Report from subfolder
- Report from subfolder

Code trying to get there (not thinking of subfolders yet):

rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
CatalogItem[] items = rs.ListChildren("/", false);
foreach (CatalogItem ci in items)
{
cmbRapporten.Nodes.Add(ci.Name);
CatalogItem[] test = rs.ListChildren("/" + ci.Name.ToString(), false);
foreach(CatalogItem ti in test)
{
cmbRapporten.Nodes.Add(ti.Name);
}
}
EXPLANATION

I ask for the root folder's children (not recursive) and then list them in my treeview cmbRapporten then I create a new CatalogItem[] = test, where I list the children of the current folder in the CatalogItem[] items. Everything appears fine but it's all in one line down. How do I couple them with their parents folder.

greetings
|||Hi,

so I got there to fill the treeview not looking at subfolders with this code (pretty simple if you ask me ;))

[CODE]
ReportingService2005 rs = new ReportingService2005();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
CatalogItem[] items = rs.ListChildren("/", false);
foreach (CatalogItem item in items)
{
cmbRapporten.Nodes.Add(item.Name);
if (item.Type.ToString() == "Folder")
{
CatalogItem[] childs = rs.ListChildren("/" + item.Name.ToString(), false);
foreach (CatalogItem child in childs)
{
cmbRapporten.Nodes[counter].Nodes.Add(child.Name);
}
counter++;
}
}
[/CODE]

Gives me a nice treeview in the designer but I'm still not content ;).

If one of the items in the object childs is a folder then there should be added another subnode. I'll visualize it for better understanding:

Now i support:

+ FOLDER
-REPORT
-REPORT
-SUBFOLDER
-REPORT

But I want the subfolder to display it's items too. So I will have to make a generic method and then call it with two parameters i thought. The string path wich is the path on the report server that should List it's children. Second of al I have to pass the Node number. But sometimes I will have to pass one node number while other times I will have to pass multiple node numbers... I have no idea to make such an method. Could somebody help with this.

Do I make sense or should I rephrase everything.

Greetings

No comments:

Post a Comment