mercredi 29 juin 2016

Kendo MVC Grid / Details Grid - child grid's controller not getting called


Does Id have to be an integer or it can be string? It seems like in my case #=INVOICE# is getting value but it Read method to controller not sure why not getting called.

I tried looking at this example: http://demos.telerik.com/kendo-ui/grid/detailtemplate

code:
@(Html.Kendo().Grid<OpenInvoicesInfo>()
              .Name("grid")
  .Columns(columns =>
  {
      columns.Bound(p => p.INVOICE).ClientTemplate("<input type='checkbox' value='#= INVOICE #' class='testclass' />").Width(4);
      columns.Bound(i => i.INVOICE).Width(15);
      ...     
  })
      .ClientDetailTemplateId("OrdersTemplate")
  .DataSource(dataSource => dataSource
      .Ajax()
      .PageSize(8)
      .Read(read => read.Action("GetOpenInvoices", "Maint", new { cust = Request.QueryString["cust"] }))
  )

)

<script id="OrdersTemplate" type="text/kendo-tmpl">
@(Html.Kendo().Grid<CustomerComments>()
                            .Name("grid_#=INVOICE#")
            .Columns(columns =>
            {
                columns.Bound(o => o.INVOICE).Width(15);
                columns.Bound(o => o.Comment).Width(40);
            })
            .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(10)
                .Read(read => read.Action("GetCustomerComments", "Maint", new { invoices = "#=INVOICE#" }))
            )
            .Pageable()
            .Sortable()
            .ToClientTemplate()
)

    Controller:
    public ActionResult GetCustomerComments([DataSourceRequest] DataSourceRequest request, string invoices)
    {

        List<JNI.Enterprise.Contracts.CustomerComments> customer = InvoiceService.GetCustomerComments(invoices);

        return Json(customer.ToDataSourceResult(request));
    }

I will really appreciate if someone can reply. Does it only work if it is in entity framework. I am calling GetCustomerComments from a stored procedure. It is loading the first grid fine but not calling details grid's controller method.


Aucun commentaire:

Enregistrer un commentaire