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

Issue with Master and Detail Grid

1 Answer 44 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shawn
Top achievements
Rank 1
Shawn asked on 06 Nov 2015, 07:20 PM

The master grid is not recognized as a master grid.

Detail Template

<script id="inviteehistorytemplate" type="text/x-kendo-template">
    @(Html.Kendo().Grid<BusinessEntities.ChangeHistory>()
        .Name("grid_#=EventID#") // make sure the Name is unuque
        .Columns(c =>
        {
            c.Bound(h => h.FieldName);
            c.Bound(h => h.NewValue);
            c.Bound(h => h.OldValue);
            c.Bound(h => h.UpdatedBy);
            c.Bound(h => h.UpdatedOn);
        })
    .DataSource(dataSource =>
        // Make request to GetInviteeChangeHistory and provide the current ContactID as a route parameter
        dataSource
        .Ajax()
        .Read(read => read.Action("GetInviteeChangeHistory", "Contacts", new { contactId = Model.Contact.ContactID, eventId = "#=EventID#" }))
    )
        .Scrollable()
        .ToClientTemplate()
    )
</script>

Master grid code. Grid is populated by the model.

 

@(Html.Kendo().Grid(Model.EventHistory)
    .Name("contacteventhistorygrid")
    .Sortable()
    .Scrollable()
    .ClientDetailTemplateId("inviteehistorytemplate")
    .NoRecords()
    .HtmlAttributes(new { @class = "eb-table-header" })
    .Columns(c =>
        {
            c.Bound(e => e.EventID).Title("Event ID");
            c.Bound(e => e.EventDate).Title("Event Date").Format("{0: MM/dd/yyyy}");
            c.Bound(e => e.Name).Title("Event Name");
            c.Bound(e => e.TotalSeats).Title("Total Seats");
            c.Bound(e => e.PartyVenue2).Title("Theatre");
            c.Bound(e => e.PartyVenue1).Title("Party Venue");
        })
  
    .Events(events => events.DataBound("Contacts.fn.eventhistory_DataBound"))
)

JavaScript

 

eventhistory_DataBound: function (e) {
        this.expandRow(this.tbody.find("tr.k-master-row").first());
}

Screenshot of the results

 

 

1 Answer, 1 is accepted

Sort by
0
Shawn
Top achievements
Rank 1
answered on 06 Nov 2015, 09:38 PM

Solved this issue by adding a DataSource to the master grid.

 

 

Tags
Grid
Asked by
Shawn
Top achievements
Rank 1
Answers by
Shawn
Top achievements
Rank 1
Share this question
or