protected void AddMenuItem(MenuItem mi, bool leftSide = true) { Control c = null; switch (mi.MenuItemType) { case (int)MenuItemTypeEnum.Button: Button b = new Button(); b.Text = mi.Text; if (!string.IsNullOrWhiteSpace(mi.OnClickJavascript)) { b.Attributes.Add("onclick", mi.OnClickJavascript); } c = b; break; case (int)MenuItemTypeEnum.DropDownList: DropDownList ddl = new DropDownList(); ListItem li = new ListItem(); li = new ListItem(mi.Text); li.Attributes.Add("OptionGroup", "Process Views"); ddl.Items.Add(li); DataTable dt = Filtering.LoadReportViews(-1, mi.ID); if (dt != null) { foreach (DataRow dr in dt.Rows) { li = new ListItem(dr["ViewName"].ToString()); li.Attributes.Add("OptionGroup", dr["WTS_RESOURCEID"].ToString() == "0" ? "Process Views" : "Custom Views"); li.Attributes.Add("MyView", dr["CREATEDBY"].ToString() == HttpContext.Current.User.Identity.Name ? "1" : "0"); li.Attributes.Add("ViewID", dr["UserReportViewID"].ToString()); ddl.Items.Add(li); } } ddl.ID = mi.ReportName; ddl.Enabled = true; c = ddl; break; case (int)MenuItemTypeEnum.Text: Literal t = new Literal(); t.Text = mi.Text; c = t; break; case (int)MenuItemTypeEnum.EditableDropDownList: iti_Tools_Sharp.DropDownList eddl = new iti_Tools_Sharp.DropDownList(); li = new ListItem(mi.Text); li.Attributes.Add("OptionGroup", "Process Views"); eddl.Items.Add(li); dt = Filtering.LoadReportViews(-1, mi.ID); if (dt != null) { foreach (DataRow dr in dt.Rows) { li = new ListItem(dr["ViewName"].ToString()); li.Attributes.Add("OptionGroup", dr["WTS_RESOURCEID"].ToString() == "0" ? "Process Views" : "Custom Views"); li.Attributes.Add("MyView", dr["CREATEDBY"].ToString() == HttpContext.Current.User.Identity.Name ? "1" : "0"); li.Attributes.Add("ViewID", dr["UserReportViewID"].ToString()); eddl.Items.Add(li); } } eddl.ID = mi.ReportName; eddl.Enabled = true; c = eddl; break; case (int)MenuItemTypeEnum.Image: Image i = new Image(); i.Height = 15; i.Width = 15; i.ImageUrl = mi.ImgSrc; i.AlternateText = mi.Text; i.ToolTip = mi.Text; i.Style["padding-left"] = "3px"; i.Style["padding-right"] = "3px"; i.Style["vertical-align"] = "middle"; i.Style["cursor"] = "pointer"; if (!string.IsNullOrWhiteSpace(mi.OnClickJavascript)) { i.Attributes.Add("onclick", mi.OnClickJavascript); } c = i; break; case (int)MenuItemTypeEnum.ItiMenu: iti_Tools_Sharp.Menu menu = new iti_Tools_Sharp.Menu(); DataSet dsMenu = new DataSet(); dsMenu.ReadXml(this.Server.MapPath("XML/WTS_Menus.xml")); string ReportTypeRelatedItemsRef = "CRGridRelatedItem"; switch (mi.ID) { case (int)ReportTypeEnum.CRReport: ReportTypeRelatedItemsRef = "CRGridRelatedItem"; break; } if (dsMenu.Tables.Count > 0 && dsMenu.Tables[0].Rows.Count > 0) { if (dsMenu.Tables.Contains(ReportTypeRelatedItemsRef)) { menu.DataSource = dsMenu.Tables[ReportTypeRelatedItemsRef]; menu.DataValueField = "URL"; menu.DataTextField = "Text"; menu.DataIDField = "id"; if (dsMenu.Tables[ReportTypeRelatedItemsRef].Columns.Contains(ReportTypeRelatedItemsRef + "_id_0")) { menu.DataParentIDField = ReportTypeRelatedItemsRef + "_id_0"; } menu.ID = "menuRelatedItems"; menu.DataImageField = "ImageType"; menu.Text = "Related Items <img id=imgRelatedItemsMenu alt=Expand Menu title=Show Related Items Options src=Images/menuDown_Black.gif />"; menu.Button = true; menu.DataBind(); menu.ClientClickEvent = "openMenuItem"; } } c = menu; break; } ((PlaceHolder)Page.Master.FindControl("MenuBar" + (leftSide ? "Left" : "Right") + "PlaceHolder")).Controls.Add(c); }
void grdMD_GridRowDataBound(object sender, GridViewRowEventArgs e) { columnData.SetupGridBody(e.Row); GridViewRow row = e.Row; formatColumnDisplay(ref row); //add edit link string itemId = row.Cells[DCC.IndexOf("WTS_SystemID")].Text.Trim(); if (itemId == "0") { row.Style["display"] = "none"; } row.Attributes.Add("itemID", itemId); if (CanView) { iti_Tools_Sharp.DropDownList eddl = new iti_Tools_Sharp.DropDownList(); eddl.ID = "eddl" + itemId; ListItem item = new ListItem(string.IsNullOrWhiteSpace(Server.HtmlDecode(row.Cells[DCC.IndexOf("WTS_SYSTEM")].Text.Replace(" ", " ").Trim())) ? row.Cells[DCC.IndexOf("WTS_SystemID")].Text.Replace(" ", " ").Trim() : Server.HtmlDecode(row.Cells[DCC.IndexOf("WTS_SYSTEM")].Text.Replace(" ", " ").Trim()), row.Cells[DCC.IndexOf("WTS_System")].Text.Replace(" ", " ").Trim()); eddl.Items.Insert(0, item); eddl.Style["width"] = "98%"; eddl.Enabled = true; row.Cells[DCC.IndexOf("WTS_SYSTEM")].Controls.Add(eddl); row.Cells[DCC.IndexOf("DESCRIPTION")].Controls.Add(WTSUtility.CreateGridTextBox("Description", itemId, Server.HtmlDecode(row.Cells[DCC.IndexOf("DESCRIPTION")].Text.Replace(" ", " ").Trim()))); row.Cells[DCC.IndexOf("SORT_ORDER")].Controls.Add(WTSUtility.CreateGridTextBox("SORT_ORDER", itemId, Server.HtmlDecode(row.Cells[DCC.IndexOf("SORT_ORDER")].Text.Replace(" ", " ").Trim()))); bool archive = false; if (row.Cells[DCC.IndexOf("ARCHIVE")].HasControls() && row.Cells[DCC.IndexOf("ARCHIVE")].Controls[0] is CheckBox) { archive = ((CheckBox)row.Cells[DCC.IndexOf("ARCHIVE")].Controls[0]).Checked; } else if (row.Cells[DCC.IndexOf("ARCHIVE")].Text == "1") { archive = true; } row.Cells[DCC.IndexOf("ARCHIVE")].Controls.Clear(); row.Cells[DCC.IndexOf("ARCHIVE")].Controls.Add(WTSUtility.CreateGridCheckBox("Archive", itemId, archive)); } string dependencies = Server.HtmlDecode(row.Cells[DCC.IndexOf("WorkItem_Count")].Text).Trim(); int count = 0, waCount = 0; int.TryParse(dependencies, out count); string workAreas = Server.HtmlDecode(row.Cells[DCC.IndexOf("WorkArea_Count")].Text).Trim(); int.TryParse(workAreas, out waCount); if (!CanEdit || count > 0 || waCount > 0) { //don't allow delete Image imgBlank = new Image(); imgBlank.Height = 10; imgBlank.Width = 10; imgBlank.ImageUrl = "Images/Icons/blank.png"; imgBlank.AlternateText = ""; row.Cells[DCC["X"].Ordinal].Controls.Add(imgBlank); } else { //add delete button row.Cells[DCC["X"].Ordinal].Controls.Add(WTSUtility.CreateGridDeleteButton(itemId, row.Cells[DCC.IndexOf("WTS_System")].Text.Trim())); } if (!string.IsNullOrEmpty(itemId) && itemId != "0") { //add expand/collapse buttons HtmlGenericControl divChildren = new HtmlGenericControl(); divChildren.Style["display"] = "table-row"; divChildren.Style["text-align"] = "right"; HtmlGenericControl divChildrenButtons = new HtmlGenericControl(); divChildrenButtons.Style["display"] = "table-cell"; divChildrenButtons.Controls.Add(createShowHideButton(true, "Show", itemId)); divChildrenButtons.Controls.Add(createShowHideButton(false, "Hide", itemId)); HtmlGenericControl divChildCount = new HtmlGenericControl(); divChildCount.InnerText = string.Format("({0})", waCount.ToString()); divChildCount.Style["display"] = "table-cell"; divChildCount.Style["padding-left"] = "2px"; divChildren.Controls.Add(divChildrenButtons); divChildren.Controls.Add(divChildCount); //buttons to show/hide child grid row.Cells[DCC["A"].Ordinal].Controls.Clear(); row.Cells[DCC["A"].Ordinal].Controls.Add(divChildren); //add child grid row for Task Items Table table = (Table)row.Parent; GridViewRow childRow = createChildRow(itemId); table.Rows.AddAt(table.Rows.Count, childRow); } }