//protected override void RenderFieldForDisplay(System.Web.UI.HtmlTextWriter output)
//{
// string[] valueArray;
// List<SPListItem> objNodeCollectionForDisplay = new List<SPListItem>();
// string objNodeTitle = string.Empty;
// string objLookupColumn = string.Empty;
// StringBuilder Query = new StringBuilder();
// SPList objTaskList;
// objLookupColumn = objTreeViewControlField.ParentLookup;
// if (this.ListItemFieldValue != null)
// {
// objTaskList = SPContext.Current.Web.Lists[objTreeViewControlField.ListName];
// if (objTaskList != null)
// {
// valueArray = this.ListItemFieldValue.ToString().Split(new string[] { ";#" }, StringSplitOptions.RemoveEmptyEntries);
// if (this.ControlMode == SPControlMode.Display)
// {
// objNodeCollectionForDisplay = CreateNodeCollectionForDisplay(valueArray);
// }
// List<SPListItem> results = (from SPListItem item in objNodeCollectionForDisplay
// where (new SPFieldLookupValue(Convert.ToString(item[objTreeViewControlField.ParentLookup])).LookupValue == null)
// orderby item.ID
// select item).ToList();
// foreach (SPListItem objLstItem in results)
// {
// CreateTree(objLstItem["Title"].ToString(), null, objNodeCollectionForDisplay, objLstItem[objTreeViewControlField.ValueColumn].ToString());
// }
// objTreeView.RenderControl(output);
// }
// }
//}
#endregion Overridden RenderFieldForDisplay Method for Display Mode
#region CreateTree Method
private void CreateTree(string RootNode, string[] valueArray, List <SPListItem> objNodeCollection, string DisplayValue)
{
TreeNode objTreeNode;
objTreeView.ShowLines = true;
objTreeNode = new TreeNode(DisplayValue, RootNode);
objTreeView.Nodes.Add(objTreeNode);
objTreeNode.SelectAction = TreeNodeSelectAction.None;
/*******Check for parent node if no child exists Show Checkbox -- Start***************/
if (this.ControlMode != SPControlMode.Display)
{
if (valueArray != null && this.ControlMode == SPControlMode.Edit && valueArray.Contains(objTreeNode.Value))
{
objTreeNode.ShowCheckBox = true;
objTreeNode.Checked = true;
}
else
{
objTreeNode.ShowCheckBox = true;
}
}
/*******Check for parent node if no child exists Show Checkbox -- End***************/
TreeNodeCollection objTreenodeColn = GetChildNode(RootNode, valueArray, objNodeCollection);
foreach (TreeNode childnode in objTreenodeColn)
{
objTreeNode.ChildNodes.Add(childnode);
childnode.SelectAction = TreeNodeSelectAction.None;
if (valueArray != null && this.ControlMode == SPControlMode.Edit && valueArray.Contains(objTreeNode.Value))
{
objTreeNode.ShowCheckBox = true;
objTreeNode.Checked = true;
}
else if (this.ControlMode == SPControlMode.Display)
{
objTreeNode.ShowCheckBox = false;
}
else
{
objTreeNode.ShowCheckBox = true;
}
}
objExpandValue = objTreeViewControlField.ExpandCollapse.ToString();
if (objExpandValue.Equals("True"))
{
objTreeView.ExpandAll();
}
else
{
objTreeView.CollapseAll();
}
}