Vitantonio
Top achievements
Rank 1
Vitantonio
asked on 16 May 2012, 03:17 PM
Hi,
I use the example of this page http://piyushbhatt.blogspot.it/2011/12/kendoui-adding-menu-using-web-service.html,
but if want add a sub-menu i use parentItem = parentItem.find("li:contains('" + listParent[i] + "')");
The sub menu is add but then image right-arrow not show
Why ?
Thanks
I use the example of this page http://piyushbhatt.blogspot.it/2011/12/kendoui-adding-menu-using-web-service.html,
but if want add a sub-menu i use parentItem = parentItem.find("li:contains('" + listParent[i] + "')");
The sub menu is add but then image right-arrow not show
Why ?
Thanks
8 Answers, 1 is accepted
0
Hello Vitantonio,
This sounds like a bug that was fixed in the service pack which was released this week.
All the best,
Kamen Bundev
the Telerik team
This sounds like a bug that was fixed in the service pack which was released this week.
All the best,
Kamen Bundev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Vitantonio
Top achievements
Rank 1
answered on 18 May 2012, 08:42 AM
Hi,
I have use the sp version, but the problem remains :(
I have use the sp version, but the problem remains :(
0
Hello Vitantonio,
Can you post the part of javascript code in which you add the items to the Menu?
All the best,
Kamen Bundev
the Telerik team
Can you post the part of javascript code in which you add the items to the Menu?
All the best,
Kamen Bundev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Vitantonio
Top achievements
Rank 1
answered on 18 May 2012, 09:44 AM
This is Javascripts:
$.ajax(
{ type: "POST",
contentType: "application/json; charset=utf-8",
url: "MenuMain.aspx",
async: true,
dataType: "json",
success: function (menulist) {
//Create Menu
var menu = $("#menuMain").kendoMenu().data("kendoMenu");
var parentItem = null;
$(menulist).each(function (rec) {
var listParent = this.ParentList.split("|");
if (listParent.length <= 1) {
parentItem = menu.element.children("li:contains('" + this.ParentTitle + "')");
} else {
parentItem = menu.element.children("li:contains('" + listParent[0] + "')");
}
for (i = 1; i < listParent.length; i++) {
parentItem = parentItem.find("li:contains('" + listParent[i] + "')");
}
if (this.ParentTitle == '' || parentItem.length == 0) {
menu.append({ text: this.Title, url: this.Link });
}
else
menu.append([{ text: this.Title, url: this.Link }], parentItem);
});
},
error: function (msg) {
alert(msg);
}
});
This Is Web Service
List<JsonData.MenuItem> ItemsMenu = new List<JsonData.MenuItem>();
JsonData.MenuItem ItemMenu;
XElement XMLMenu = XElement.Load(Server.MapPath("~/MainMenu.sitemap"));
var ListData = XMLMenu.Descendants()
.Where(element => element.FirstAttribute.Name.LocalName.Contains("url"))
.Select(nd => new
{
parentTitle = nd.Parent.Attribute("title").Value,
title = nd.Attribute("title").Value,
url = nd.Attribute("url").Value,
Count = nd.Elements().Count(),
Level = GetLevel(nd, 0),
ParentList = GetParentList(nd, "")
});
foreach (var v in ListData)
{
ItemMenu = new JsonData.MenuItem();
ItemMenu.ParentTitle = v.parentTitle;
ItemMenu.Title = v.title;
ItemMenu.Link = v.url;
ItemMenu.IconUrl = "";
ItemMenu.Child = v.Count;
ItemMenu.Level = v.Level;
ItemMenu.ParentList = (v.ParentList != String.Empty) ? v.ParentList.Substring(1) : v.ParentList;
ItemsMenu.Add(ItemMenu);
}
JavaScriptSerializer s = new JavaScriptSerializer();
String strResponse = s.Serialize(ItemsMenu);
This is SiteMap
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode title="">
<siteMapNode url="" title="Gestione" description="Gestione">
<siteMapNode url="Richiesta.aspx" title="Nuova Richiesta" description="Nuova Richiesta" />
<siteMapNode url="Scheduler.aspx" title="Calendario Attività " description="Calendario Attività " />
</siteMapNode>
<siteMapNode url="" title="Ditte/Agenzie" description="Ditte/Agenzie">
<siteMapNode url="Ditte.aspx" title="Ditte" description="Ditte" />
<siteMapNode url="Agenzie.aspx" title="Agenzie" description="Agenzie" />
</siteMapNode>
<siteMapNode url="" title="Personale" description="Personale">
<siteMapNode url="Privati.aspx" title="Privati" description="Privati" />
<siteMapNode url="Tecnici_CPA.aspx" title="Tecnici CPA" description="Tecnici CPA" />
<siteMapNode url="Personale_Agenzia.aspx" title="Personale Agenzia" description="Personale Agenzia" />
</siteMapNode>
<siteMapNode url="" title="Amministrazione" description="Amministrazione">
<siteMapNode url="" title="Sicurezza" description="Sicurezza">
<siteMapNode url="Profili.aspx" title="Profili" description="Profili" />
<siteMapNode url="Utenti.aspx" title="Utenti" description="Utenti" />
<siteMapNode url="ChangePassword.aspx" title="Cambia Password" description="Cambia Password utente" />
<siteMapNode url="Log.aspx" title="Tracciato Attività " description="Tracciato Attività " />
</siteMapNode>
<siteMapNode url="" title="Tabelle" description="Tabelle">
<siteMapNode url="Tabelle.aspx" title="Tabelle" description="Tabelle" />
</siteMapNode>
<siteMapNode url="Uffici.aspx" title="Uffici" description="Uffici" />
<siteMapNode url="Parametri.aspx" title="Parametri Generali" description="Parametri Generali" />
</siteMapNode>
<siteMapNode url="Account/SignOut.aspx" title="Sign Out" description="Uscita" />
</siteMapNode>
</siteMap>
-------------------------------------------------------------------------
In ItemMenu.ParentList i save the list of sub-menu otherwise menu.element.children("li:contains('" + this.ParentTitle + "')"); select always the first one menu.
Thanks
$.ajax(
{ type: "POST",
contentType: "application/json; charset=utf-8",
url: "MenuMain.aspx",
async: true,
dataType: "json",
success: function (menulist) {
//Create Menu
var menu = $("#menuMain").kendoMenu().data("kendoMenu");
var parentItem = null;
$(menulist).each(function (rec) {
var listParent = this.ParentList.split("|");
if (listParent.length <= 1) {
parentItem = menu.element.children("li:contains('" + this.ParentTitle + "')");
} else {
parentItem = menu.element.children("li:contains('" + listParent[0] + "')");
}
for (i = 1; i < listParent.length; i++) {
parentItem = parentItem.find("li:contains('" + listParent[i] + "')");
}
if (this.ParentTitle == '' || parentItem.length == 0) {
menu.append({ text: this.Title, url: this.Link });
}
else
menu.append([{ text: this.Title, url: this.Link }], parentItem);
});
},
error: function (msg) {
alert(msg);
}
});
This Is Web Service
List<JsonData.MenuItem> ItemsMenu = new List<JsonData.MenuItem>();
JsonData.MenuItem ItemMenu;
XElement XMLMenu = XElement.Load(Server.MapPath("~/MainMenu.sitemap"));
var ListData = XMLMenu.Descendants()
.Where(element => element.FirstAttribute.Name.LocalName.Contains("url"))
.Select(nd => new
{
parentTitle = nd.Parent.Attribute("title").Value,
title = nd.Attribute("title").Value,
url = nd.Attribute("url").Value,
Count = nd.Elements().Count(),
Level = GetLevel(nd, 0),
ParentList = GetParentList(nd, "")
});
foreach (var v in ListData)
{
ItemMenu = new JsonData.MenuItem();
ItemMenu.ParentTitle = v.parentTitle;
ItemMenu.Title = v.title;
ItemMenu.Link = v.url;
ItemMenu.IconUrl = "";
ItemMenu.Child = v.Count;
ItemMenu.Level = v.Level;
ItemMenu.ParentList = (v.ParentList != String.Empty) ? v.ParentList.Substring(1) : v.ParentList;
ItemsMenu.Add(ItemMenu);
}
JavaScriptSerializer s = new JavaScriptSerializer();
String strResponse = s.Serialize(ItemsMenu);
This is SiteMap
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode title="">
<siteMapNode url="" title="Gestione" description="Gestione">
<siteMapNode url="Richiesta.aspx" title="Nuova Richiesta" description="Nuova Richiesta" />
<siteMapNode url="Scheduler.aspx" title="Calendario Attività " description="Calendario Attività " />
</siteMapNode>
<siteMapNode url="" title="Ditte/Agenzie" description="Ditte/Agenzie">
<siteMapNode url="Ditte.aspx" title="Ditte" description="Ditte" />
<siteMapNode url="Agenzie.aspx" title="Agenzie" description="Agenzie" />
</siteMapNode>
<siteMapNode url="" title="Personale" description="Personale">
<siteMapNode url="Privati.aspx" title="Privati" description="Privati" />
<siteMapNode url="Tecnici_CPA.aspx" title="Tecnici CPA" description="Tecnici CPA" />
<siteMapNode url="Personale_Agenzia.aspx" title="Personale Agenzia" description="Personale Agenzia" />
</siteMapNode>
<siteMapNode url="" title="Amministrazione" description="Amministrazione">
<siteMapNode url="" title="Sicurezza" description="Sicurezza">
<siteMapNode url="Profili.aspx" title="Profili" description="Profili" />
<siteMapNode url="Utenti.aspx" title="Utenti" description="Utenti" />
<siteMapNode url="ChangePassword.aspx" title="Cambia Password" description="Cambia Password utente" />
<siteMapNode url="Log.aspx" title="Tracciato Attività " description="Tracciato Attività " />
</siteMapNode>
<siteMapNode url="" title="Tabelle" description="Tabelle">
<siteMapNode url="Tabelle.aspx" title="Tabelle" description="Tabelle" />
</siteMapNode>
<siteMapNode url="Uffici.aspx" title="Uffici" description="Uffici" />
<siteMapNode url="Parametri.aspx" title="Parametri Generali" description="Parametri Generali" />
</siteMapNode>
<siteMapNode url="Account/SignOut.aspx" title="Sign Out" description="Uscita" />
</siteMapNode>
</siteMap>
-------------------------------------------------------------------------
Thanks
0
Hi Vitantonio,
I tested it here by appending an item to a sub menu item and the right arrow shows up okay. Check this jsFiddle:
Can you modify it to reproduce your issue?
Additionally - I've noticed that you build a flat JSON object on the server and you iterate it on the client and add each element from it separately. While this is not wrong, it is a bit of an overkill since you can initialize the Menu along with its sub items from a hierarchical JSON object - check Initialize the Menu from JSON object in the documentation.
Kind regards,
Kamen Bundev
the Telerik team
I tested it here by appending an item to a sub menu item and the right arrow shows up okay. Check this jsFiddle:
Can you modify it to reproduce your issue?
Additionally - I've noticed that you build a flat JSON object on the server and you iterate it on the client and add each element from it separately. While this is not wrong, it is a bit of an overkill since you can initialize the Menu along with its sub items from a hierarchical JSON object - check Initialize the Menu from JSON object in the documentation.
Kind regards,
Kamen Bundev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Vitantonio
Top achievements
Rank 1
answered on 22 May 2012, 09:37 AM
Hi,
I update the code...
but in this situation function...i don't understand..:(
http://jsfiddle.net/QfhHW/2/
I update the code...
but in this situation function...i don't understand..:(
http://jsfiddle.net/QfhHW/2/
0
Hello Vitantonio,
Can you try my previous suggestion to initialize the Menu from a single server-generated JSON object? Maybe that would help?
All the best,
Kamen Bundev
the Telerik team
Can you try my previous suggestion to initialize the Menu from a single server-generated JSON object? Maybe that would help?
All the best,
Kamen Bundev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Vitantonio
Top achievements
Rank 1
answered on 29 May 2012, 04:39 PM
Hi,
I have create the DataSource and then assigned to menu and now function.
Thanks
I have create the DataSource and then assigned to menu and now function.
Thanks