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

[Solved] Master/detail Grid detail binding doesn't fire

1 Answer 126 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.
william
Top achievements
Rank 1
william asked on 19 Jul 2011, 12:22 PM
Hi All,

I have the following code Where Covers is a complex type on my view.
@(Html.Telerik().Grid<GRID.ViewModels.ComputerBreakdownRiskViewModel>()
    .Name("risksGrid")
    .Sortable()
    .DataKeys(keys => keys.Add(r => r.ComputerBreakdownRiskID))
    .ToolBar(commands => commands.Custom().ButtonType(GridButtonType.ImageAndText).Text("Add New Risk").HtmlAttributes(new { @class = "addRisk" }).Action("Create", "ComputerBreakdownRisk", new { policyZoneID = ViewData["policyZoneID"], sectionID = ViewData["sectionID"] }))
    .DataBinding(dataBinding =>
        {
            dataBinding.Ajax()
                .Select("_RisksIndex", "ComputerBreakdownSection", new { policyZoneID = ViewData["policyZoneID"], sectionID = ViewData["sectionID"] });
        })
    .Columns(columns =>
          {
              columns.Bound(r => r.ComputerBreakdownRiskID).Title("Edit")
                  .Template(r => @Html.ActionLink("Edit", "Edit", "ComputerBreakdownRisk",
                  new { riskID = r.ComputerBreakdownRiskID, policyZoneID = ViewData["policyZoneID"], sectionID = ViewData["sectionID"] }, new { @class = "editLink" }));
              columns.Bound(r => r.ComputerBreakdownRiskID).Title("Delete")
                  .Template(r => @Html.ActionLink("Delete", "Delete", "ComputerBreakdownRisk",
                  new { riskID = r.ComputerBreakdownRiskID, policyZoneID = ViewData["policyZoneID"], sectionID = ViewData["sectionID"] }, new { @class = "deleteLink" }));
              columns.Bound(r => r.Description).Width(200);
              columns.Bound(r => r.IndemnityPeriod).Width(50);
              columns.Bound(r => r.ManuallyRated);
                    
          })
    .RowAction(row =>
    {
        if (row.IsAlternate) { row.HtmlAttributes["style"] = "background:aliceblue;"; }
    })
    .ClientEvents(events => events.OnRowDataBound("covers_onRowDataBound"))
    .DetailView(detailView => detailView.ClientTemplate(
        Html.Telerik().Grid<GRID.ViewModels.ComputerBreakdownRiskViewModel>()
            .Name("detailview_<#= ComputerBreakdownRiskID #>")
            .Columns(columns =>
            {
                columns.Bound(co => co.Covers.Select(m => m.Name));
            })
            .DataBinding(dataBinding =>
            {
                dataBinding.Ajax()
                    .Select("_CoverDetailForRiskHierarchyAjax", "ComputerBreakdownRisk", new { riskID = "<#= ComputerBreakdownRiskID #>" });
            })
            .ToHtmlString()
    ))                          
)

When the grid attempts to load it errors on the detail bound column with : Bound columns require a field or property access expression. If I replace the binding with a non complex column such that I map :
columns.Bound(co => co.Description);
then I get no complaint, My Master data displays, but the Description on my detail is empty.  in all cases, my _coverDetailForRiskHierearchyAjax method seems not to get fired. So how does the detail bind to the master on initial load? If it was binding I would expect to at least see the description even though I really want an enumeration of my complex type

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 19 Jul 2011, 02:54 PM
Hi William,

 Indeed bound columns support only member expressions. You cannot use such a complex expression in a bound column. 

The rest of the code looks correct and should work properly unless there is some JavaScript error. If you need further assistance please send us a small project reproducing the problem.

All the best,
Atanas Korchev
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Grid
Asked by
william
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or