private List<SmartMenuItem> GetChildMenus(SmartMenuItem parentMenu)
 {
     List<SmartMenuItem> childMenus = new List<SmartMenuItem>();
     foreach (SmartMenuItem item in ChildMenus)
     {
         if (item.Parent == parentMenu.MenuId)
         {
             childMenus.Add(item);
         }
     }
     return childMenus;
 }
Exemplo n.º 2
0
 protected override void OnLoad(EventArgs e)
 {
     object objDs = this.GetObjByID(this.DataSourceID);
     if (objDs != null && objDs is WebDataSource)
     {
         WebDataSource wds = (WebDataSource)objDs;
         DataTable menuTable = null;
         if (wds.SelectAlias != null && wds.SelectAlias != "" && wds.SelectCommand != null && wds.SelectCommand != "")
             menuTable = wds.CommandTable;
         else if (wds.DataMember != null && wds.DataMember != "")
             menuTable = wds.InnerDataSet.Tables[wds.DataMember];
         if (menuTable != null && isBaseFieldSet())
         {
             foreach (DataRow row in menuTable.Rows)
             {
                 string id = row[this.MenuIDField] == null ? "" : row[this.MenuIDField].ToString();
                 string parent = row[this.MenuParentField] == null ? "" : row[this.MenuParentField].ToString();
                 string text = row[this.MenuTextField] == null ? "" : row[this.MenuTextField].ToString();
                 string url = "", imgUrl = "", hoverImgUrl = "";
                 if (IsUrlFieldSet())
                     url = row[this.MenuUrlField] == null ? "" : row[this.MenuUrlField].ToString();
                 if (IsImageFieldSet())
                     imgUrl = row[this.MenuImageUrlField] == null ? "" : row[this.MenuImageUrlField].ToString();
                 if (IsHoverImageFieldSet())
                     hoverImgUrl = row[this.MenuHoverImageUrlField] == null ? "" : row[this.MenuHoverImageUrlField].ToString();
                 SmartMenuItem item = new SmartMenuItem(id, parent, text, imgUrl, hoverImgUrl, url);
                 this.Items.Add(item);
             }
         }
     }
     base.OnLoad(e);
     ClientScriptManager csm = Page.ClientScript;
     Type cstype = this.Page.GetType();
     if (!csm.IsClientScriptIncludeRegistered(cstype, "refScript"))
     {
         if (IsClientMain())
             csm.RegisterClientScriptInclude(cstype, "refScript", "stm31.js");
         else
             csm.RegisterClientScriptInclude(cstype, "refScript", "../stm31.js");
     }
 }
 private void removeChildMenus(SmartMenuItem parentMenuItem)
 {
     if (parentMenuItem == null)
         return;
     List<SmartMenuItem> childMenus = this.GetChildMenus(parentMenuItem);
     if (childMenus.Count > 0)
     {
         foreach (SmartMenuItem item in childMenus)
         {
             removeChildMenus(item);
         }
     }
     this.Collection.Remove(parentMenuItem);
 }