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

Open Child View and Pass parent model to grid

1 Answer 99 Views
Grid
This is a migrated thread and some comments may be shown as answers.
technotes
Top achievements
Rank 1
technotes asked on 30 Sep 2015, 09:09 PM

I have created two views ​Shipment and Shipment Lines,

The Shipment has the header info, and of course the lines is the details.  How do I have an action link form the parent grid to the child view, and pass the correct order Id (the model) to the line read action?

 This is the Shipment View:  

@(Html.Kendo().Grid<Portal.Model.DAX.PurchaseShipment>()
        .Name("Grid")
        .Columns(columns =>
        {
            columns.Bound(c => c.CompanyId).Width(160);
            columns.Bound(c => c.VendAccount).Width(120)
            columns.Bound(c => c.DeliveryMode).Width(120);
            columns.Bound(c => c.VendShipId).Width(120);
            columns.Bound(c => c.ShipmentDate).Width(140).Format("{0:MM/dd/yy}");
            columns.Bound(c => c.EstimateShipmentDate).Width(140).Format("{0:MM/dd/yy}");
            columns.Bound(c => c.SourceOfData).Hidden(true).IncludeInMenu(false);
            columns.Bound(c => c.RecVersion).Title("Rec Version").Hidden(true).IncludeInMenu(false);
            columns.Bound(c => c.RecId).Title("RecId").Hidden(true).IncludeInMenu(false);
            columns.Bound(c => c.CompanyId).ClientTemplate(@Html.ActionLink("Lines", "Lines", "Shipment", new { CompanyId = "#=CompanyId#", RecId = "#=RecId#" }, "").ToHtmlString()).Width(120);
            columns.Command(command => {
                command.Edit();
                command.Destroy();
 
            }).Width(180);
        })
        .ToolBar(toolbar =>
        {
            toolbar.Create().Text("Add Shipment").HtmlAttributes(new { @title = "Add Shipment" });
            toolbar.Excel();
        })
        .Editable(editable => editable.Mode(GridEditMode.PopUp))
        .DataSource(dataSource => dataSource
            .Ajax()
            .PageSize(20)
            .Model(model => model.Id(p => p.CompanyId))
            .Read(read => read.Action("Read", "Shipment").Type(HttpVerbs.Post))
            .Create(create => create.Action("Create", "Shipment").Type(HttpVerbs.Post))
            .Update(update => update.Action("Update", "Shipment").Type(HttpVerbs.Post))
            .Destroy(destroy => destroy.Action("Destroy", "Shipment"))
        )
    )

And the Lines View: (I know the model has the PurchaseShipment data, I had textboxes populating it for testing)

@using Portal.Model.DAX
@model PurchaseShipment
 
    @(Html.Kendo().Grid<Portal.Models.ShipmentLinesViewModel>()
      .Name("grid")
      .Columns(columns =>
      {
          columns.Bound(c => c.CompanyId);
          columns.Bound(c => c.ShipId);
          columns.Bound(c => c.PurchId);
          columns.Bound(c => c.PurchaseOrderId);
          columns.Bound(c => c.PurchaseOrderDate);
          columns.Bound(c => c.InventTransId);
          columns.Bound(c => c.LineNum);
          columns.Bound(c => c.ItemId);
          columns.Bound(c => c.UnitId);
          columns.Bound(c => c.QuantityOrdered);
          columns.Bound(c => c.QuantityShipped);
          columns.Bound(c => c.RecVersion);
          columns.Bound(c => c.RecId);
          columns.Command(command => { command.Edit(); }).Width(180);
      })
      .ToolBar(toolbar =>
      {
          toolbar.Excel();
      })
      .Editable(editable => editable.Mode(GridEditMode.InLine))
      .Pageable()
      .Sortable(sortable =>
      {
          sortable.SortMode(GridSortMode.MultipleColumn);
      })
      .Filterable()
      .Scrollable()
      .DataSource(dataSource => dataSource
          .Ajax()
          .Model(model => model.Id(p => p.CompanyId))
          .Read(read => read.Action("Lines_Read", "Shipment"))
          .Update(update => update.Action("Lines_Update", "Shipment"))
      )
    )

 

So the issue is that when the read for the lines happens it doesn't have the Shipment Model available so I can grab the correct line data.  How do I pass from one view to the next, and pass the model to the read action?

1 Answer, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 02 Oct 2015, 01:30 PM

Hello technotes,

 

Based on the provided code I am not completely sure at what point the details Grid should be shown (on row selection from the first Kendo UI Grid for example).

 

I would need some more information about your scenario in order to provide proper solution for the current case. 

 

Regards,
Boyan Dimitrov
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
technotes
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or