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

[Solved] Outter/Master Grid Server Bound and Child/Detail Grid

0 Answers 47 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.
Hiram
Top achievements
Rank 1
Hiram asked on 21 May 2012, 07:48 PM

Outer/Master Grid Server Bound and Child/Detail Grid Client/Ajax Bound

I want to have the outer/master grid server bound and the row detail Ajax bound, but they should only be invoked when the user clicks to see details.  I got it to work with the outer grid server bound and the detail grid client bound, but all the child grids were loaded (the GridAction method was called for all rows).

I tried what is on this post: http://www.telerik.com/community/forums/aspnet-mvc/grid/master-server-binding-and-child-ajax-binding.aspx

Here is a portion of my code. If I remove the Render() at the end of the child grid, nothing will show when the user clicks  to see details.

Html.Telerik().Grid(Model.Loans)

    .Name("LoansHierarchyGrid")

    .Columns(columns =>

    {

      columns.Template(

          @<text>

            @Html.ActionLink(@item.DealName, "Details""Deal"new { id = item.DealName }, null)

          </text>

        ).Title("Deal").Width(160).Hidden(@Model.CallerID > 0);

 

      var loanNumberCol = columns.Template(

        @<text>

            @Html.ActionLink(@item.LoanNumber, "Details""Loan"new { id = item.LoanNumber }, null)

          </text>

      ).Title("Loan Number").Width(150);

      if (Model.CallerID != 0)

      {

        loanNumberCol.FooterTemplate(@<text>Count: @Model.LoansCount</text>);

      }

 

      columns.Bound(l => l.CollateralName).Title("Collateral Name").Width(180);

 

      var endingScheduledBalanceCol = columns.Bound(l => l.EndingScheduledBalance)

        .Title("Ending Sched. Bal.").Width(150).Format("${0:n}").HtmlAttributes(new { @class = "alignRight" });

      if (Model.CallerID != 0)

      {

        endingScheduledBalanceCol.Aggregate(aggregates => aggregates.Sum())

          .FooterTemplate(@<text>Sum: @item.Sum.Format("${0:n}")</text>);

      }

 

      columns.Bound(l => l.InterestRate).Title("Interest Rate").Width(120).Format("{0:p}").HtmlAttributes(new { @class = "alignRight" });

      columns.Bound(l => l.MaturityDate).Title("Maturity Date").Width(120).HtmlAttributes(new { @class = "alignRight" }).Format("{0:d}");

      columns.Bound(l => l.EventDate).Title("Event Date").Width(120).Format("{0:d}").HtmlAttributes(new { @class = "alignRight" });

      columns.Bound(l => l.EventReason).Title("Event Reason").Width(120);

      columns.Template(

          @<text>

            @LPAMSSite.CT.GetYesNo(item.IsActive)

          </text>

        ).Title("SS Active").Width(100).Hidden(@Model.CallerID > 0);

      columns.Bound(l => l.FinalResolutionStatus).Title("Resolution").Width(180);

      columns.Bound(l => l.ResolutionDate).Title("Resolution Date").Width(135).Format("{0:d}").HtmlAttributes(new { @class = "alignRight" });

      columns.Template(

          @<text>

            @LPAMSSite.CT.GetYesNo(item.IsInBankruptcy)

          </text>

        ).Title("Bankruptcy").Width(100).Hidden(@Model.CallerID > 0);

 

      var propertyCountCol = columns.Bound(l => l.PropertyCount)

        .Title("Properties").Width(100).HtmlAttributes(new { @class = "alignRight" });

      if (Model.CallerID != 0)

      {

        propertyCountCol.Aggregate(aggregates => aggregates.Sum())

          .FooterTemplate(@<text>Sum: @item.Sum</text>);

      }

    })

    .DetailView(detailView => detailView.Template(e =>    

    {

      Html.Telerik().Grid<LPAMSSiteModel.Property>()

        .Name("Properties_" + e.LoanID)

        .Columns(columns =>

        {

          columns.Bound(p => p.Name).Title("Property Name").Width(233).ClientTemplate(

            Html.ActionLink("<#= Name #>""Details""Property"new { id = "<#= PropertyID #>" }, null).ToString());

          columns.Bound(p => p.Type).Width(150);

          columns.Bound(p => p.MainAddressLine1).Title("Address")

            .ClientTemplate("<a href='http://maps.google.com/?q=<#= FullAddress(MainAddressLine1, MainAddressLine2) #>' target='_blank'><#= FullAddress(MainAddressLine1, MainAddressLine2) #></a>");

          columns.Bound(p => p.LoanCount).Title("Loan Count").Width(100).HtmlAttributes(new { @class = "alignRight" });

        })

        .DataBinding(dataBinding => dataBinding.Ajax().Select("_PropertiesHierarchyAjax""Property"new { id = e.LoanID }))

        .NoRecordsTemplate("Loading...")

        .ClientEvents(events => events.OnDataBound("teleriGridRrestoreNoRecordsText"))

        .Sortable()

        .Footer(false)

        .Render();

    }))

    .NoRecordsTemplate("Loading...")

    .ClientEvents(events => events.OnDataBound("teleriGridRrestoreNoRecordsText"))

    .Pageable(paging => paging.PageSize(100).Enabled(Model.CallerID == 0))

    .Groupable(grouping => grouping.Enabled(Model.CallerID == 0))

    .Resizable(resizing => resizing.Columns(true))

    .Filterable(filtrable => filtrable.Enabled(Model.CallerID == 0))

    .HtmlAttributes(new { @class = "SearchTable" })

    .Footer(true)

    .Sortable(sorting => sorting.OrderBy(sortOrder => sortOrder.Add(o => o.LoanNumber).Ascending()))

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