Tsob ntoo saib ntawv qiv hauv NTXHUAB 2007

Kuv tuaj los Moss Devs,
Yog koj nrhiav Treeview webpart los tso saib lub tsev qiv ntawv hauv daim ntawv nyob hauv cov ntoo pom.
Yog tsis muaj kev tawm ntawm lub thawv webpart muaj los tso saib lub tsev qiv ntawv ntaub ntawv nyob rau hauv Treeview.

Yog googling nws thaum pib khiav hauj lwm rau qhov hauj lwm no. Kuv tau mus ob peb webparts uas yog siv java tsab ntawv ntsaws rau tsob ntoo pom. Kuv xav ntawm tus kheej webpart mus kav daim ntawv qiv hauv tsob ntoo pom tswj.

Kuv tau tsim cov webpart siv .net 2.0 cov tswj saib tsob ntoo thiab fetching cov ntaub ntawv qiv ntaub ntawv los ntawm lub toolpart los kav cov ntaub ntawv rau tsob ntoo pom.

Siv cov cai nram qab no mus ntsaws cov nplooj ntawv ntawm tsob ntoo pom los ntawm lub tsev qiv ntawv hauv daim ntawv.

pej xeem tsis muaj dabtsis TraverseFolder(SPFolder sis,AspControls.TreeNode ntawm)
{
TreeNode tNode = tshiab System.Web.UI.WebControls.TreeNode(ceev.Lub npe);
sim
{
Yog hais tias (ceev.Lub npe != “Cov ntaub ntawv”)
{
foreach (SPFolder fldr nyob rau hauv lub tais ceev tseg.SubFolders)
{
Yog hais tias (fldr.Lub npe != “Cov ntaub ntawv”)
{
TreeNode trn = tshiab System.Web.UI.WebControls.TreeNode(fldr.Lub npe);
tNode = TraverseFiles(fldr, trn);
rNode.ChildNodes.Add(tNode);
}
}

foreach (SPFile txhuam rau nplaub tshev.Ntaub ntawv)
{
TreeNode trnChild = tshiab System.Web.UI.WebControls.TreeNode(cov ntaub ntawv.Lub npe, “”, “~/_layouts/images/” + cov ntaub ntawv.IconUrl, cov ntaub ntawv.ServerRelativeUrl.ToString(), “”);
//trv.Nodes.Add(trnChild);
rNode.ChildNodes.Add(tNode);
}
}
}

ntes (Kos e)
{
Console.WriteLine(e.Message);
}
}

pej xeem TreeNode TraverseFiles(SPFolder fldr, AspControls.TreeNode ntawm)
{
sim
{
foreach (SPFile ntaub ntawv nyob rau hauv fldr.Ntaub ntawv)
{
AspControls.TreeNode trnChild = tshiab System.Web.UI.WebControls.TreeNode(cov ntaub ntawv.Lub npe, “”, “~/_layouts/images/” + cov ntaub ntawv.IconUrl, cov ntaub ntawv.ServerRelativeUrl.ToString(), “”);
ntawm.ChildNodes.Add(trnChild);
}
bool bRecurseFolders = fldr.SubFolders.Count > 0 ? tseeb : tsis tseeb;

Yog hais tias (bRecurseFolders)
{
rau (rau cov menyuam kuv = 0; Kuv < fldr.SubFolders.Count; i++) { TreeNode trnChild = new System.Web.UI.WebControls.TreeNode(fldr.SubFolders[i].Name); node.ChildNodes.Add(TraverseFiles(fldr.SubFolders[i], trnChild)); } } } catch (Exception e) { Console.WriteLine(e.Message); } return node; } Use the Traverse Folder function and pass the root element of the document library as parameter. Now you got a Tree view with appropriate leaf nodes. Render it in your webpart project 🙂

5 Comments rau tsob ntoo saib ntawv qiv hauv NTXHUAB 2007

sau ntawv cia

Koj siv tau qhov cim npe no HTML

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>