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

Razor + Grid + DetailView

6 Answers 282 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Michael Munnis
Top achievements
Rank 1
Michael Munnis asked on 15 Nov 2010, 03:44 PM
I'm running into some problems getting DetailView to work in Grid under the Razor view engine.  This is probably me putting the wrong syntax in the template area, but I couldn't find any examples that didn't use another control in the template.  I'm not sure how to enter just XHTML markup in there. 

<!--  start fax-table ............................. -->
@Html.Telerik().Grid(Model).Name("Grid").Columns(columns => {
    columns.Bound(o => o.Facilityname).Width(400);
    columns.Bound(o => o.Deptname).Width(300);
    columns.Bound(o => o.Fullname).Width(200);
    columns.Bound(o => o.Runnumber).Width(100);
    columns.Bound(o => o.Processeddate).Width(220);
    columns.Bound(o => o.Faxphone).Width(200);
    columns.Bound(o => o.Winfaxerror).Width(450);
}).DetailView(detailView => detailView.Template(e =>
{
        @<text>
        <div>
            <ul>
                <li>Company sent from: @e.Companyname </li>
                <li>Rule name that spawned fax: @e.Rule</li>
                <li>Report faxed: @e.Processeddate</li>
                <li>Run Nbr: @e.Runnumber</li>
                <li>Destination: @e.Facilityname</li>
                <li>Patient on trip faxed: @e.Fullname</li>
                <li>Fax Nbr: @e.Faxphone</li>
                <li>Date submitted: @e.Processeddate</li>
                <li>Who submitted: @e.Whoprocessed</li>
                <li>Fax status msg: @e.Winfaxerror</li>
                <li>Send method: @e.Sendmethod</li>
                <li>Date last modified: @e.Lastmodifieddate</li>
                <li>Who last modified: @e.Whomodified</li>
            </ul>
        </div>
        </text>;                                       
})).Sortable().Pageable(pager => pager.PageSize(15)).Filterable()
<!--  end fax-table................................... -->

Thanks for any assistance.

6 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 15 Nov 2010, 07:22 PM
Hi Michael Munnis,

 You can try this:

.DetailView(@<text>
<ul><li>@item.CompanyName</li></ul>
</text>)

Regards,

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
        @<text>
        <div>
            <ul>
                <li>Company sent from: @e.Companyname </li>
                <li>Rule name that spawned fax: @e.Rule</li>
                <li>Report faxed: @e.Processeddate</li>
                <li>Run Nbr: @e.Runnumber</li>
                <li>Destination: @e.Facilityname</li>
                <li>Patient on trip faxed: @e.Fullname</li>
                <li>Fax Nbr: @e.Faxphone</li>
                <li>Date submitted: @e.Processeddate</li>
                <li>Who submitted: @e.Whoprocessed</li>
                <li>Fax status msg: @e.Winfaxerror</li>
                <li>Send method: @e.Sendmethod</li>
                <li>Date last modified: @e.Lastmodifieddate</li>
                <li>Who last modified: @e.Whomodified</li>
            </ul>
        </div>
        </text>
        @<text>
        <div>
            <ul>
                <li>Company sent from: @e.Companyname </li>
                <li>Rule name that spawned fax: @e.Rule</li>
                <li>Report faxed: @e.Processeddate</li>
                <li>Run Nbr: @e.Runnumber</li>
                <li>Destination: @e.Facilityname</li>
                <li>Patient on trip faxed: @e.Fullname</li>
                <li>Fax Nbr: @e.Faxphone</li>
                <li>Date submitted: @e.Processeddate</li>
                <li>Who submitted: @e.Whoprocessed</li>
                <li>Fax status msg: @e.Winfaxerror</li>
                <li>Send method: @e.Sendmethod</li>
                <li>Date last modified: @e.Lastmodifieddate</li>
                <li>Who last modified: @e.Whomodified</li>
            </ul>
        </div>
        </text>
0
Michael Munnis
Top achievements
Rank 1
answered on 15 Nov 2010, 08:55 PM
When I use @item.Companyname (or anything else from my model), I get the following error:

'Telerik.Web.Mvc.UI.Fluent.GridDetailViewBuilder<Contracts.IFaxes>' does not contain a definition for 'Companyname' and no extension method 'Companyname' accepting a first argument of type 'Telerik.Web.Mvc.UI.Fluent.GridDetailViewBuilder<Contracts.IFaxes>' could be found

If I replace @item.Companyname with just some random text, the page renders, but the detail view is empty.   This also happens in your example on this site:  http://mvcdemo.chiplex.com/grid/detailsserverside

Anything else you can think to try that might resolve this?

Kind Regards,
Mike

0
a c
Top achievements
Rank 1
answered on 16 Nov 2010, 03:14 AM
I recommend that you use the Ajax binding, it can work.
http://mvcdemo.chiplex.com/grid/detailsajax
0
Accepted
Atanas Korchev
Telerik team
answered on 16 Nov 2010, 08:24 AM
Hello,

 I am attaching a sample project which shows how to use the server detail template with razor. Here is the relevant code:

@(Html.Telerik().Grid(new[] { new GridRazorDetailView.Controllers.Customer { ID = 1, Name = "Customer 1" } })
      .Name("Grid")
      .Columns(columns =>
      {
        columns.Bound(c => c.ID).Width(200);
        columns.Bound(c => c.Name);
      })
      .DetailView(view => view.Template(@<ul>
        <li>@item.ID</li>
        <li>@item.Name</li>
      </ul>))
)

Regards,
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
0
Michael Munnis
Top achievements
Rank 1
answered on 16 Nov 2010, 03:38 PM
Thank you Atanas, that worked perfectly!
0
Ulfar
Top achievements
Rank 1
answered on 22 Jul 2011, 10:46 AM
Works perfectly!
Tags
General Discussions
Asked by
Michael Munnis
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Michael Munnis
Top achievements
Rank 1
a c
Top achievements
Rank 1
Ulfar
Top achievements
Rank 1
Share this question
or