I have a pure object model that looks like this:
[Serializable]
public class NavigationModel
{
private IList<App> _applications;
public IList<App> Applications
{
get { return _applications; }
set { _applications = value; }
}
}
Each App contains an IList of Features. I want to map this object model to the menu control. Right now I have hierarchy through the object model and I want to keep it this way. How would I do this?
Here is some of what I have tried with no success:
_navigationModel = _navigationService.LoadData();
TopMenu.DataSource = _navigationModel.Applications;
TopMenu.DataFieldID = "Id";
//TopMenu.DataMember = "Applications";
//TopMenu.DataTextField = "Name";
//TopMenu.DataValueField = "RelativePath";
TopMenu.Flow = ItemFlow.Horizontal;
RadMenuItemBinding appBinding = new RadMenuItemBinding();
appBinding.Depth = 1;
appBinding.TextField = "Name";
appBinding.ValueField = "RelativePath";
appBinding.DataMember = "Features";
TopMenu.DataBindings.Add(appBinding);
TopMenu.DataBind();
Thanks
10 Answers, 1 is accepted
0
Hi Scott,
Please check this help article:
Binding to object-based data sources
Sincerely yours,
Veskoni
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Please check this help article:
Binding to object-based data sources
Sincerely yours,
Veskoni
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Hi Scott,
Please check this help article:
Binding to object-based data sources
Sincerely yours,
Veskoni
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Please check this help article:
Binding to object-based data sources
Sincerely yours,
Veskoni
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0

Scott
Top achievements
Rank 1
answered on 17 Sep 2008, 02:05 PM
That helps when binding to an object model. However it does not solve my problem with ParentIDs. I need to find a way to define the nested hierarchy as you can see I do not want to bind one List to the grid with ParentIDs. Each object has nested beneath it it's own Lists of it's children.
I was hoping I could use the BindingCollection to do this but have had no success yet.
Thanks,
Scott
0
Hello Scott,
At the time being only the suggested way of defining hierarchy is supported. In your case I suggest you traverse your objects and create menu items on the fly.
Regards,
Albert
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
At the time being only the suggested way of defining hierarchy is supported. In your case I suggest you traverse your objects and create menu items on the fly.
Regards,
Albert
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0

Scott
Top achievements
Rank 1
answered on 18 Sep 2008, 09:50 PM
I redesigned my objects and now I have the menus displaying flat (no hierarchy). The code i have is below. Do you see any reason why it wouldn't be rendering properly?
aspx:
<telerik:RadMenu ID="TopMenu" Runat="server" />
model:
public class NavigationModel
{
protected int _id;
protected string _name;
protected string _description;
protected int? _parentId;
protected string _relativePath;
public int Id
{
get { return _id; }
set { _id = value; }
}
public string Name
{
get { return _name; }
set { _name = value; }
}
public string Description
{
get { return _description; }
set { _description = value; }
}
public int? ParentId
{
get { return _parentId; }
set { _parentId = value; }
}
public string RelativePath
{
get { return _relativePath; }
set { _relativePath = value; }
}
}
Code-Behind:
TopMenu.DataFieldID = "Id";
TopMenu.DataTextField = "Name";
TopMenu.DataNavigateUrlField = "RelativePath";
TopMenu.DataFieldParentID = "ParentId";
IList<NavigationModel> navigationModel = _navigationService.LoadData();
TopMenu.DataSource = navigationModel;
TopMenu.DataBind();
aspx:
<telerik:RadMenu ID="TopMenu" Runat="server" />
model:
public class NavigationModel
{
protected int _id;
protected string _name;
protected string _description;
protected int? _parentId;
protected string _relativePath;
public int Id
{
get { return _id; }
set { _id = value; }
}
public string Name
{
get { return _name; }
set { _name = value; }
}
public string Description
{
get { return _description; }
set { _description = value; }
}
public int? ParentId
{
get { return _parentId; }
set { _parentId = value; }
}
public string RelativePath
{
get { return _relativePath; }
set { _relativePath = value; }
}
}
Code-Behind:
TopMenu.DataFieldID = "Id";
TopMenu.DataTextField = "Name";
TopMenu.DataNavigateUrlField = "RelativePath";
TopMenu.DataFieldParentID = "ParentId";
IList<NavigationModel> navigationModel = _navigationService.LoadData();
TopMenu.DataSource = navigationModel;
TopMenu.DataBind();
0
Hello Scott,
Please make sure the root elements have their ParentID property set to null. Also make sure you are using the current official release of RadMenu as it is the first version so far which supports binding to object collections. Additionally you can check this online example.
Kind regards,
Albert
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Please make sure the root elements have their ParentID property set to null. Also make sure you are using the current official release of RadMenu as it is the first version so far which supports binding to object collections. Additionally you can check this online example.
Kind regards,
Albert
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0

Scott
Top achievements
Rank 1
answered on 19 Sep 2008, 03:42 PM
I have the latest version running and I've recompiled. The good news is that it doesn't show all the menu items flatly, the child items are not longer being displayed as parents. However the children items aren't being displayed at all even as children objects of the parent menus.
I've stepped though my code and verified that the Id/ParentId values match and should be linked properly. Is there a property that you have to set to tell the menu to drop down? This should be working.
Thanks,
Scott
0
Accepted
Hello Scott,
No, setting the DataFieldID/DataFieldParentID properties would be enough. I suspect the child items which don't appear in the menu do not have a corresponding parent item. Please check if this is not the case.
Regards,
Albert
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
No, setting the DataFieldID/DataFieldParentID properties would be enough. I suspect the child items which don't appear in the menu do not have a corresponding parent item. Please check if this is not the case.
Regards,
Albert
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0

Scott
Top achievements
Rank 1
answered on 22 Sep 2008, 05:45 PM
I have an image of me stepping through the code, with the object model fully expanded so that you can see the code and the object model is correct, however this forum will not let me attach images. Can I email it to you? If so what email address?
0

Scott
Top achievements
Rank 1
answered on 22 Sep 2008, 08:13 PM
I got it fixed by adding the following to my web.config:
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>