/// <summary> /// BindSysEnum /// </summary> /// <param name="key">Key</param> /// <param name="isShowKey">isShowKey</param> /// <param name="alllocal">alllocal</param> public void BindSysEnum(string key, bool isShowKey, AddAllLocation alllocal) { Sys.SysEnums ens = new BP.Sys.SysEnums(key); this.Items.Clear(); if (alllocal == AddAllLocation.TopAndEnd || alllocal == AddAllLocation.Top) { this.Items.Add(new ListItem(">>", "all")); } foreach (SysEnum en in ens) { if (this.SelfIsShowVal) { this.Items.Add(new ListItem(en.IntKey + " " + en.Lab, en.IntKey.ToString())); } else { ListItem li = new ListItem(en.Lab, en.IntKey.ToString()); //li.Attributes.CssStyle.Add("style","color:"+en.Style); //li.Attributes.Add("color",en.Style); //li.Attributes.Add("style","color:"+en.Style); //li.Attributes.A.CssStyle.Add("color",en.Style); this.Items.Add(li); } } if (alllocal == AddAllLocation.TopAndEnd || alllocal == AddAllLocation.End) { this.Items.Add(new ListItem("-=全部=-", "all")); } //this.BindEntities(ens.ToEntitiesNoName(),isShowKey,alllocal); }
/// <summary> /// 根据一个实体建立一个Entity /// </summary> /// <param name="ens">ens</param> /// <param name="refkey">refkey</param> /// <param name="reftext">reftext</param> public ToolbarDDL(string id, Entities ens, string refkey, string reftext, bool isShowKey, AddAllLocation where) { this.CssClass = "DDL" + WebUser.Style; this.ID = id; this.BindEntities(ens, refkey, reftext, isShowKey, true, where); }
/// <summary> /// BindEntities /// </summary> /// <param name="ens">ens</param> /// <param name="refkey">refkey</param> /// <param name="reftext">reftext</param> /// <param name="isShowKey">is show key</param> /// <param name="isClearItems">is clear item</param> /// <param name="where">where the -=all=- location.</param> public void BindEntities(Entities ens, string refkey, string reftext, bool isShowKey, bool isClearItems, AddAllLocation where) { string val = SystemConfig.GetConfigXmlEns("ShowTextLen", this.SelfBindKey); int len = 0; if (val != null) { len = int.Parse(val); } if (isClearItems) { this.Items.Clear(); } if (where == AddAllLocation.Top || where == AddAllLocation.TopAndEnd) { ListItem li = new ListItem("-=全部=-", "all"); this.Items.Add(li); } if (SystemConfig.MaxDDLNum <= ens.Count) { ListItem liMore = new ListItem(); liMore.Text = "请用更多..."; liMore.Value = "all"; this.Items.Add(liMore); BP.Web.Controls.BPToolBar blb = (BP.Web.Controls.BPToolBar) this.Parent; blb.AddLab("<a href=\"javascript:onDDLSelectedMore('" + this.ID + "', '" + this.EnsName + "', '" + ens.ToString() + "', 'No','Name')\" >...</a>"); return; } /// #warning 处理多选择的问题 int maxNum = SystemConfig.MaxDDLNum; string text = ""; string key = ""; int i = 0; foreach (Entity en in ens) { text = en.GetValStringByKey(reftext); key = en.GetValStringByKey(refkey); ListItem li = new ListItem(); if (len > 0) { if (text.Length > len) { li.Attributes["title"] = text; text = text.Substring(0, len); } } if (isShowKey) { li.Text = key + " " + text; li.Value = key; } else { li.Text = text; li.Value = key; } this.Items.Add(li); i++; if (i >= maxNum) { li = new ListItem(); li.Text = "请用更多..."; li.Value = "all"; this.Items.Add(li); BP.Web.Controls.BPToolBar blb = (BP.Web.Controls.BPToolBar) this.Parent; blb.AddLab("<a href=\"javascript:onDDLSelectedMore('" + this.ID + "', '" + this.EnsName + "', '" + ens.ToString() + "', 'No','Name')\" >...</a>"); // this.AutoPostBack = true; // this.SelectedIndexChanged += new EventHandler(ToolbarDDL_SelectedIndexChanged); //li.Attributes["class"] = "sssssss"; //li.Attributes["bgColor"] = "Red"; // writer.AddStyleAttribute(HtmlTextWriterStyle.Color, "Red"); // li.Attributes[ //ToolbarBtn btn = new ToolbarBtn(); //btn.Text="..."; // blb.AddBtn("Btn_" // blb.Attributes.Add("selcecChange", "alert('hello')"); //blb.Attributes.Add("onclick", "onDDLSelectedMore('" + blb.ClientID + "')"); // this.Attributes["onclick"] = "alert('hello')"; // li.Attributes["onclick"] = "alert('hello')"; //this.Items.Add(li); //System.IO.TextWriter; //System.Web.UI.HtmlTextWriter htw = new System.Web.UI.HtmlTextWriter(; //this.AddAttributesToRender(HtmlTextWriterAttribute.o // this.AddAttributesToRender(htw); break; } } if (where == AddAllLocation.End || where == AddAllLocation.TopAndEnd) { ListItem li = new ListItem("-=全部=-", "all"); this.Items.Add(li); //this.Items. } }
/// <summary> /// BindEntities /// </summary> /// <param name="ens">EntitiesNoName</param> /// <param name="isShowKey">是否显示编码</param> /// <param name="local">all位置</param> public void BindEntities(EntitiesOID ens, bool isShowKey, AddAllLocation alllocal) { BindEntities(ens, "OID", "Name", isShowKey, true, alllocal); }