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

[Solved] Recursive

1 Answer 81 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Radu
Top achievements
Rank 1
Radu asked on 27 Jun 2011, 10:11 PM
EDIT: Sorry, Title should read "Recursive PartialView in Grid DetailView"

Hi,
I using MVC 3, EF4.1, Telerik 2011.1.315.
Is it possible to recursively load a PartialView within a grid's DetailsView.
My logic involves a Tree-like structure of Groups. The pseudo POCO looks like this:

class Group {
    int GroupId{ };
    int ParentGroupID{ };
    virtual IList<Group> SubGroups { }
}

I have a Ajaxed Grid set up in a PartialView (partial.ascx) which int urn is embedded
in a View (view.aspx). In the grid's DetailView, I hava a TabStrip. In the first tab,
I'm trying to recursively reload the PartialView so that the grid looks like this:

...
.DataBinding(dataBinding => { dataBinding.Ajax()
    .Select("_Index", "Groups", new { parentId = "<#= ParentGroupId #>" })
})
.DetailView(detailView => detailView.ClientTemplate(
Html.Telerik().TabStrip().Name("TabStrip_<#= GroupId #>").SelectedIndex(0)
.Items(items =>
{
    items.Add().Text("SubGroups")
        .LoadContentFrom("GetPartial", "Groups");
}).ToHtmlString()
...

On the Controller, I have the initial call, the Ajax call, and the call
for .LoadContentFrom():
public ActionResult Index()
{
    return PartialView();
}
  
[GridAction]
public ActionResult _Index(int? parentId)
{
    List<Group> list = new List<Group>();
    if (parentId != null)
        list = _Repository.Groups.Where(g => g.GroupId == parentId).First().SubGroups;
    else
        list = _Repository.Groups;
    return Json(new GridModel(list));
}
public ActionResult GetPartial()
{
return PartialView("partial");
}


The result: The outer-most grid loads perfectly; Both Index and _Index actions fire
respectively. However, when I click the "+" to expand a row, the GetPartial action
fires, then Index, but the _Index Ajax call doesn't fire again, and my child grid
(while rendered very nicely) remains empty. 

What canI do to fix this?

Many thanks,

Radu
EDIT: Sorry for the ludicrous code blocks.

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 28 Jun 2011, 06:57 AM
Hi Radu,

 The reason this does not work is because the grids have identical Name attributes. Those are rendered as HTML id attributes and as a result the second grid does not work. You should make sure the Name of the child grid is unique.

All the best,
Atanas Korchev
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
Grid
Asked by
Radu
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or