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

3 posts, 0 answers
  1. Gaurav
    Gaurav avatar
    14 posts
    Member since:
    Nov 2014

    Posted 22 Jun Link to this post

    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()
        )
    </script>
              
            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.
  2. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 27 Jun Link to this post

    Hello Gaurav,

    You can use whatever primitive you need for the details template. On my end the read method is called with both string and int ID in the overload of the action controller (respectively, in the modal too).

    Are there any JS errors in the console? Does the request is at least sent (i.e., appears in the NET tab of the browser's dev toolbar)? It is possible to be called but for some reason not accessible (e.g., server-side error). 

    Regards,
    Ianko
    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
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Gaurav
    Gaurav avatar
    14 posts
    Member since:
    Nov 2014

    Posted 27 Jun Link to this post

    It is working. Thank you for your help.
Back to Top