Error muliti-column and scrolling when use load menu from database SQL ?

2 posts, 0 answers
  1. DucAnh
    DucAnh avatar
    24 posts
    Member since:
    Aug 2011

    Posted 18 Oct 2011 Link to this post

    Hello everybody!
    I have a problem when I use radmenu. I need load menu form a SQL database. I done, but I can't use multi-column (Error in IE9 and Firefox ) and when I use scrolling : my radmenu is 2 rows (Error in IE9 but not in FireFox).
    Have you any ideas! Thank you very much!
    My code is upload in link:
        http://www.mediafire.com/?8d1g24e6i5ee1tz
    Or:
    Code behind:
    string connectionString = @"Server=PHAMDUCANH-PC\SQLEXPRESS; database=TestDB;Integrated Security = True";
            string command = "SELECT * FROM Menu";
            SqlDataAdapter da = new SqlDataAdapter();
            DataSet ds = new DataSet();
             
     
            protected void Page_Load(object sender, EventArgs e)
            {   
     
                if (!IsPostBack)
                {               
                    SqlConnection conn = new SqlConnection(connectionString);
                    conn.Open();
                    SqlCommand cmd = new SqlCommand(command, conn);
                    da.SelectCommand = cmd;
                    da.Fill(ds);
                    ds.AcceptChanges();
                    DataSet dsMenu = new DataSet();
                    dsMenu.Tables.Add(ds.Tables[0].Copy());
                    if (dsMenu != null && dsMenu.Tables.Count > 0 && dsMenu.Tables[0].Rows.Count > 0)
                    {                  
                        mnuMenu.Items.Clear();
                        var drGoc = dsMenu.Tables[0].Select("ParentMenuID = -1");
                        if (drGoc != null && drGoc.Length > 0)
                        {
                            foreach (DataRow dr in drGoc)
                            {
                                RadMenuItem item = new RadMenuItem();
                                item.Value = dr["MenuID"].ToString().Trim();
                                item.Text = dr["Header"].ToString().Trim();
                                CreateTree(item, dsMenu);
                                mnuMenu.Items.Add(item);
                            }
                        }
                    }
                }
            }
     
            public void CreateTree(RadMenuItem node, DataSet ds)
            {
                try
                {
                    node.Items.Clear();
                    var p = ds.Tables[0].Select("ParentMenuID=" + node.Value);
                    if (p != null && p.Length > 0)
                    {
                        foreach (DataRow dr in p)
                        {
                            RadMenuItem item = new RadMenuItem();
                            item.Value = dr["MenuID"].ToString().Trim();
                            item.Text = dr["Header"].ToString().Trim();
                            if (dr["Path"].ToString().Trim().Length > 0)
                            {
                                
                                item.NavigateUrl = "~/Default.aspx?Menu=" + dr["Path"].ToString().Trim();
                            }
                            node.Items.Add(item);
                            CreateTree(item, ds);
                        }
                    }
                }
                catch
                {
                }
            }
    UI:

    <telerik:RadMenu runat="server" ID="mnuMenu" EnableRootItemScroll="true" Width="400px"
                               EnableRoundedCorners="true" EnableShadows="true" 
                               Skin="WebBlue">
               <DefaultGroupSettings Height="100px" RepeatColumns="2"/>                     
                     <Items>
                         <telerik:RadMenuItem Text = "New..." >
                             <GroupSettings Height="100px" RepeatColumns="2"></GroupSettings>
                             <Items>                                   
                                    <telerik:RadMenuItem Text="File"></telerik:RadMenuItem>
                                    <telerik:RadMenuItem Text="Folder"></telerik:RadMenuItem>
                             </Items>
                         </telerik:RadMenuItem>
                         <telerik:RadMenuItem Text="Open">
                              <GroupSettings Height="100px"></GroupSettings>
                              <Items>
                                   <telerik:RadMenuItem Text="File"></telerik:RadMenuItem>
                                    <telerik:RadMenuItem Text="Folder"></telerik:RadMenuItem>
                              </Items>
                          </telerik:RadMenuItem>
                          <telerik:RadMenuItem Text="Close">
                              <GroupSettings Height="100px"></GroupSettings>
                              <Items>
                                    <telerik:RadMenuItem Text="File"></telerik:RadMenuItem>
                                    <telerik:RadMenuItem Text="Folder"></telerik:RadMenuItem>
                              </Items>
                              </telerik:RadMenuItem>
                          <telerik:RadMenuItem Text="Save" >
                                <GroupSettings Height="100px"></GroupSettings>
                                    <Items>
                                       <telerik:RadMenuItem Text="File"></telerik:RadMenuItem>
                                       <telerik:RadMenuItem Text="Folder"></telerik:RadMenuItem>
                                   </Items>
                               </telerik:RadMenuItem>
                               <telerik:RadMenuItem Text="Save as ...">
                                   <GroupSettings Height="100px"></GroupSettings>
                                    <Items>
                                       <telerik:RadMenuItem Text="File"></telerik:RadMenuItem>
                                       <telerik:RadMenuItem Text="Folder"></telerik:RadMenuItem>
                                   </Items>
                               </telerik:RadMenuItem>                          
                           </Items>                   
                       </telerik:RadMenu>
  2. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 21 Oct 2011 Link to this post

    Hi Ducanh,

    The issue that you encounter with the RadMenu control is a bug that we are alreadya aware of. It occurs when you use both the EnableRootItemScroll and the DefaultGroupSettings (RepeatColumns) properties. We are working on resolving it but I can not give you any time frame whet it will be fixed.

    All the best,
    Kate
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top