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

[Solved] MVC Grid Detailview Tabstrip Razor

1 Answer 52 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.
Captain Awesome
Top achievements
Rank 2
Captain Awesome asked on 20 Feb 2012, 07:05 AM
I have an MVC Grid that contains a Detailview. In the detail view I am attempting to add a Tabstrip. I amusing the razor view engine.

The tab strip shows up in the View before the Grid. In other words as you look down the page you see a tab strip and then the Grid (please see attached screenshot)

The Tabstrips have uniqueID's in the DOM when the page is rendered.

Any ideas?

 

 

 

 

@(Html.Telerik().Grid(Model)
       .Name("Dockets")
       .Columns(columns =>
       {
               columns.Bound(e => e.FirstName);
               columns.Bound(e => e.LastName);
       })
       .DetailView(detailView => detailView.Template(e => // Set the server template
       {                 
           Html.Telerik().TabStrip()                    
               .Name("TabStrip_" + e.CitationViolationID)                    
               .SelectedIndex(0)                    
               .Items(items =>                    
               {                        
                items.Add().Text("Summary").Content(                       
                    @<label>Summary</label>
                );                                  
                items.Add().Text("Payment").Content(
                    @<label>Payment</label>
                );
                })                    
                .Render();   
        }))
       .RowAction(row =>
       {
               // Expand initially the detail view of the first row
               if (row.Index == 0)
               {
                   row.DetailRow.Expanded = true;
               }
       })
       .Pageable()
    )

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 20 Feb 2012, 10:14 AM
Hello Mike,

To make things work you should not render the template directly to the output.
I suggest you to use the lambda expression approach shown below (instead of the @<text></text> approach), because Razor does not support nested @<text> statements.

.DetailView(detailView => detailView.Template(e => // Set the server template
       {                
           return Html.Telerik().TabStrip()                   
               .Name("TabStrip_" + e.PersonID)                   
               .SelectedIndex(0)                   
               .Items(items =>                   
               {                       
                items.Add().Text("Summary").Content(
                    @<label>Summary</label>
                );
                items.Add().Text("Payment").Content(
                    @<label>Payment</label>
                );
                })                   
                .ToHtmlString();  
        }))

 Kind regards,
Petur Subev
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
Grid
Asked by
Captain Awesome
Top achievements
Rank 2
Answers by
Petur Subev
Telerik team
Share this question
or