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 🙂
nyob zoo,
Tau kuv tau txais haujlwm webpart txog cov cai no. Kuv yuav tshiab rau txoj kev loj hlob tab sis kuv xav no webpart nrog sorting tag nrho folders thiab cov ntaub ntawv.
Thov xa kuv kdk1983@gmail.com
nyob zoo
tau koj thov koj qhia kuv rau deatil
Iam coj tib lub prob yog hais tias koj yuav piav tias kuv nyob rau hauv cov lus yuav npaj mus li cas.nws yuav yeej greatful b thenn
nyob zoo
tau koj thov qhia kuv hauv txhawb lawv xav li cas..
thov nws cov urgentwinadbut
Hav Guyz,
Saib kuv cov CodePlex tso tawm http://techblog.udayakumar.net/2008/08/treeview-document-library-webpart-v10.html
Tsaug,
~ Uday.
qhov no txhais tau tias wat? AspControls.TreeNode ntawm pls pab