काई में ट्री दृश्य दस्तावेज़ लाइब्रेरी 2007

हाय मॉस Devs,
आप Treeview के लिए देख रहे पेड़ को देखने में दस्तावेज़ लायब्रेरी प्रदर्शित करने के लिए webpart.
TreeView में दस्तावेज़ लायब्रेरी प्रदर्शित करने के लिए उपलब्ध बॉक्स webpart का कोई बाहर नहीं है.

इस कार्य पर काम शुरू कर दिया जब मैं यह googling शुरू कर दिया. I got few webparts which is using java script to load the tree view. I thought of developing own webpart to render the document library in tree view control.

I have created the webpart using .Net 2.0 tree view control and fetching the document library information from the toolpart to render the data to tree view.

Use the following code to load the leaf information of tree view from the document library.

public void TraverseFolder(SPFolder folder,AspControls.TreeNode node)
{
TreeNode tNode = new System.Web.UI.WebControls.TreeNode(folder.Name);
कोशिश
{
if (folder.Name != “Forms”)
{
foreach (SPFolder fldr in folder.SubFolders)
{
if (fldr.Name != “Forms”)
{
TreeNode trn = new System.Web.UI.WebControls.TreeNode(fldr.Name);
tNode = TraverseFiles(fldr, trn);
rNode.ChildNodes.Add(tNode);
}
}

foreach (SPFile file in folder.Files)
{
TreeNode trnChild = new System.Web.UI.WebControls.TreeNode(file.Name, “”, “~/_layouts/images/” + file.IconUrl, file.ServerRelativeUrl.ToString(), “”);
//trv.Nodes.Add(trnChild);
rNode.ChildNodes.Add(tNode);
}
}
}

पकड़ (ई अपवाद)
{
Console.WriteLine(e.Message);
}
}

public TreeNode TraverseFiles(SPFolder fldr, AspControls.TreeNode node)
{
कोशिश
{
foreach (SPFile file in fldr.Files)
{
AspControls.TreeNode trnChild = new System.Web.UI.WebControls.TreeNode(file.Name, “”, “~/_layouts/images/” + file.IconUrl, file.ServerRelativeUrl.ToString(), “”);
node.ChildNodes.Add(trnChild);
}
bool bRecurseFolders = fldr.SubFolders.Count > 0 ? सच : झूठा;

if (bRecurseFolders)
{
के लिए (int i = 0; में < 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 to Tree View Document Library in MOSS 2007

एक उत्तर दें छोड़ दो

आप का उपयोग कर सकते हैं इन HTML टैग

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