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

not able to expand rows in master detail view

4 Answers 70 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.
test
Top achievements
Rank 1
test asked on 28 Jun 2011, 11:14 AM
I want to implement the master detail view functionality in telerik's mvc webgrid. The problem is that while the first row comes expanded by default, i cannot collapse the first row and i cannot expand the successive rows to view the data. What do i do to achieve the functionality? The code is:

@{
    
     Html.Telerik().Grid(this.Model)
                   .Name("grdPersonView")
                   .Columns(columns =>
                       {
                           columns.Bound(p => p.id);
                           columns.Bound(p => p.age);
                           columns.Bound(p => p.name);
                       })
                   .DetailView(detailview => detailview.Template(e =>
                       {
                       
                           Html.Telerik().Grid(e.GetPersons())
                               .Name("Subgrid")
                               .Columns(column =>
                                   {
                                       column.Bound(p => p.name);
                                       column.Bound(p => p.age);
                                   })
                                   .Pageable(pager => pager.PageSize(2))
                                   .Render();
                       }))
                   .RowAction(row =>
                       {
                           if (row.Index == 0)
                           {
                               row.DetailRow.Expanded = true;
                           }                        
                       })
                   .Pageable(pager => pager.PageSize(20))
                   .Sortable(sorting =>
                       {
                           sorting.SortMode(GridSortMode.MultipleColumn);
                           sorting.OrderBy(sortOrder => sortOrder.Add(p => p.id));
                       }
                           )
                           .Render();
             
    }

4 Answers, 1 is accepted

Sort by
0
john west
Top achievements
Rank 1
answered on 29 Jun 2011, 10:48 PM
Be sure to use different names for your master and detail grids.
0
john west
Top achievements
Rank 1
answered on 29 Jun 2011, 10:49 PM
Of course, if I would have looked at your source before posting, I would have quickly seen that you did name them differently :).
0
TDG
Top achievements
Rank 1
answered on 01 Dec 2011, 04:55 PM
Do you have any solution on this issue?
0
Atanas Korchev
Telerik team
answered on 02 Dec 2011, 12:25 PM
Hi,

 The sample posted here has one issue - all subgrids will have the same name which is a problem. Components need to have unique name so they can be identified and initialized client-side. This is why our example is appending the parent id in the name of the subgrids:

.DetailView(detailView => detailView.Template(e =>
        {
            %>
                <% Html.Telerik().Grid(e.Orders)
                       .Name(
"Orders_" + e.EmployeeID)

I hope this helps,
Atanas Korchev
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 Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
Grid
Asked by
test
Top achievements
Rank 1
Answers by
john west
Top achievements
Rank 1
TDG
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or