This is a migrated thread and some comments may be shown as answers.

Rad Menu - Skins

3 Answers 124 Views
Menu
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Manish
Top achievements
Rank 1
Manish asked on 22 Jul 2010, 06:09 PM
Hi,

I am using telerik control (RAD menu) skin.We are creating the menu dynamically and applying skin at item_databound. When the page is loaded first time the skin is not being applied. When the page is refreshed everything seems to be working fine. Please suggest a solution.

///Applying Skin

 

protected override void CreateChildControls()

 

{

 

try

 

{

listname =

ConfigurationManager.AppSettings["sitemenulist"] ?? defaultSiteMenuList;

 

 

List<BallMenu> sitemenu = GetMenu();

 

 

if (sitemenu.Count == 0)

 

{

 

var lblMenu = new Label {Text = "No items found in " + listname};

 

Controls.Add(lblMenu);

}

 

else

 

{

 

var ballsiteroot = new RadMenu();

 

ballsiteroot.DefaultGroupSettings.OffsetY = 6;

ballsiteroot.Skin = vista;

ballsiteroot.EnableEmbeddedSkins =

false;

 

ballsiteroot.EnableTheming =

true;

 

ballsiteroot.ItemDataBound += ballsiteroot_ItemDataBound;

ballsiteroot.DefaultGroupSettings.ExpandDirection =

ExpandDirection.Down;

 

ballsiteroot.DefaultGroupSettings.RepeatColumns = 2;

ballsiteroot.DataTextField =

"Text";

 

ballsiteroot.DataNavigateUrlField =

"Url";

 

ballsiteroot.DataFieldID =

"ID";

 

ballsiteroot.DataFieldParentID =

"ParentID";

 

ballsiteroot.DataSource = sitemenu;

ballsiteroot.DataBind();

Controls.Add(ballsiteroot);

}

 

base.CreateChildControls();

 

}

 

catch (Exception ex)

 

{

Log.Error(

"Failed to create RadMenu control", ex);

 

 

throw;

 

}

}


///Creating menu item dynamically

 

private List<BallMenu> GetMenu()

 

{

 

int cacheTime;

 

 

if (!Int32.TryParse(ConfigurationManager.AppSettings["BallSitesCachetime"], out cacheTime))

 

{

cacheTime = defaultBallSitesCacheTime;

}

 

var gotostrut = new GotoMenu(listname);

 

 

List<BallMenu> sitemenu;

 

 

object cacheItem = HttpRuntime.Cache[strUserNamecache];

 

 

if (cacheItem == null)

 

{

sitemenu = gotostrut.GenerateSiteData();

 

HttpRuntime.Cache.Insert(strUserNamecache, sitemenu, null, DateTime.Now.AddMinutes(cacheTime), TimeSpan.Zero);

 

}

 

else

 

{

sitemenu = (

List<BallMenu>) cacheItem;

 

}

 

return sitemenu ?? new List<BallMenu>();

 

}

 

private void ballsiteroot_ItemDataBound(object sender,

 

 

RadMenuEventArgs e)

 

{

 

try

 

{

 

 

var head = (string) DataBinder.Eval(e.Item.DataItem, "Text");

 

 

string[] arr = head.Split(',');

 

 

if (arr.Length > 1)

 

{

 

if (arr[1] == "1")

 

{

 

if (arr[0] == "&nbsp;")

 

{

e.Item.CssClass =

"Blue1";

 

e.Item.Text = arr[0];

e.Item.Enabled =

false;

 

e.Item.Width = 166;

}

 

else

 

{

e.Item.CssClass =

"Blue3";

 

 

FontInfo fontinfo = e.Item.Font;

 

fontinfo.Name =

"Verdana";

 

fontinfo.Bold =

true;

 

fontinfo.Size = 8;

e.Item.ForeColor =

Color.Black;

 

e.Item.Text = arr[0];

e.Item.Enabled =

false;

 

}

}

}

 

else

 

{

 

if ((int) DataBinder.Eval(e.Item.DataItem, "ID") != 1)

 

{

e.Item.Attributes.Add(

"onmouseover", "this.style.textDecoration = 'underline';this.style.cursor='hand';this.style.color='#0096BD';");

 

e.Item.Attributes.Add(

"onmouseout", "this.style.textDecoration = 'none';this.style.cursor='pointer';this.style.color='#000';");

 

e.Item.CssClass =

"Blue1";

 

 

FontInfo fontinfo = e.Item.Font;

 

fontinfo.Name =

"Verdana";

 

fontinfo.Size = 8;

e.Item.Width = 166;

}

 

else

 

{

e.Item.CssClass =

"Blue";

 

 

FontInfo fontinfo = e.Item.Font;

 

fontinfo.Name =

"Verdana";

 

fontinfo.Bold =

true;

 

e.Item.ExpandedCssClass =

"BlueOtherStates";

 

e.Item.FocusedCssClass =

"BlueOtherStates";

 

}

}

}

 

catch (Exception ex)

 

{

Log.Error(

"Failed to applying styles for item " + e.Item.Text, ex);

 

 

throw;

 

}

}

3 Answers, 1 is accepted

Sort by
0
George
Telerik team
answered on 27 Jul 2010, 03:39 PM
Hi Manish,

Thank you for contacting us.

Your code looks fine. If you could give us a sample running project that reproduces the issue it would be very helpful.

I will be glad to assist you further.

Kind regards,
George
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Manish
Top achievements
Rank 1
answered on 30 Jul 2010, 06:20 PM
Please see the CSS we are applying for this:

.RadMenu

 

.rmText

 

{

 

float:none !important;

 

 

}

 

.rmText .rmVertical .rmGroup .rmLevel1 .rmHorizontal .rmRootGroup

 

{

 

 

padding : 4px 4px 0px 14px;

 

 

}

 

.RadMenu_Vista .Blue

 

{

 

font-size:11px !important;

 

 

background: url('/_layouts/images/BallTheme/rightTabUnS.gif') no-repeat left bottom !important ;

 

 

text-decoration:none;

 

 

color: black;

 

 

line-height: 13px !important;

 

 

vertical-align:bottom !important;

 

 

padding-bottom:1px !important;

 

}

 

 

.RadMenu_Vista .Blue8

 

{

 

 

background: url('/_layouts/images/BallTheme/rightTabUnS.gif') no-repeat right bottom !important ;

 

 

text-decoration:none;

 

 

color: black;

 

 

line-height: 13px !important;

 

}

 

 

.RadMenu_Vista .Blue:hover

 

{

 

background: url('/_layouts/images/BallTheme/rightTab.gif') no-repeat left bottom !important;

 

 

color: black;

 

 

vertical-align:bottom !important;

 

 

line-height: 13px !important;

 

}

 

 

.RadMenu_Vista .BlueOtherStates

 

{

 

vertical-align:bottom !important;

 

 

/*background: #a7cfe8 !important; */

 

 

background: url('/_layouts/images/BallTheme/rightTabUnS.gif') no-repeat left bottom !important ;

 

 

color: black;

 

 

line-height: 13px !important;

 

}

 

 

.RadMenu .rmSlide

 

{

 

float:none !important;

 

 

left:-248px !important;

 

 

}

 

 

.RadMenu .rmLink

 

{

 

width:100px;

 

}

 

 

.RadMenu .rmGroup .rmText

 

{

 

padding-left:15px !important;

 

 

padding-right:15px !important;

 

 

margin:0px 0px 0px 0px !important;

 

 

}

 

 

 

.RadMenu_Vista .Blue1

 

{

 

background-color: #DFF2F6 !important ;

 

 

text-decoration:none;

 

 

color: black;

 

 

line-height: 15px !important;

 

 

font-weight:normal;

 

 

padding-left:0px !important;

 

 

text-align:left !important;

 

 

}

 

 

.RadMenu_Vista .Blue3

 

{

 

background-color: #DFF2F6!important ;

 

 

font-weight:bold;

 

 

text-decoration:none;

 

 

color: #000;

 

 

line-height: 20px !important;

 

 

}

 

 

.RadMenu_Vista .Blue2

 

{

 

background-color:#DFF2F6 !important ;

 

 

text-decoration:underline;

 

 

color: #0096BD;

 

 

font-weight:normal;

 

 

line-height: 15px !important;

 

 

padding-left:0px !important;

 

 

text-align:left !important;

 

}

 

 

.RadMenu_Vista .expandBottom

 

{

 

padding-left:0px !important;

 

 

text-align:left !important;

 

}

 

 

 

.ball-focused

 

{

 

background-color:#DFF2F6;

 

}

/* GOTO Syles */

0
Valeri Hristov
Telerik team
answered on 03 Aug 2010, 02:00 PM
Hello Manish,

This forum is for RadMenu for Silverlight. If you want to get proper response, please, post your question in the forum for RadMenu for ASP.NET.

Sincerely yours,
Valeri Hristov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Menu
Asked by
Manish
Top achievements
Rank 1
Answers by
George
Telerik team
Manish
Top achievements
Rank 1
Valeri Hristov
Telerik team
Share this question
or