Grid/Detail Grid will it work if Id is string

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

    Posted 21 Jun Link to this post

    I am trying to call detail grid/child grid but it is not getting called.

    Here is my code:

    @(Html.Kendo().Grid<OpenInvoicesInfo>()
              .Name("grid")
          .ColumnMenu(i => i.Columns(false))
          .Columns(columns =>
          {
              columns.Bound(p => p.INVOICE).ClientTemplate("<input type='checkbox' value='#= INVOICE #' class='testclass' onclick='rowCheck(this)'  />").Width(4);
              columns.Bound(i => i.INVOICE).Title("INVOICE").Width(15);
              columns.Bound(i => i.ORDER_NBR).Title("Order").Width(10);
              columns.Bound(i => i.CUST_PO_NBR).Title("CustomerPO").Width(20);
              columns.Bound(i => i.RI_FLAG).Title("RI").Width(5);
              columns.Bound(i => i.AGE_DAYS).Title("AGE_DAYS").Width(7);
              columns.Bound(i => i.AGE_GROUP).Title("AGE").Width(8);
              columns.Bound(i => i.ORIG_AMOUNT).Title("Orig Amt").Width(10);
              columns.Bound(i => i.OPEN_AMOUNT).Title("Open Amt").Width(10);

          }).Pageable(pageable => pageable
              .Refresh(true)
          )
          .Scrollable()
          .Sortable()
          .Filterable()
          .ClientDetailTemplateId("template")
          .DataSource(dataSource => dataSource
              .Ajax().UseJniErrorHandler()
              .Model(model =>
                  {
                      model.Id(i => i.INVOICE);
                      model.Field(i => i.INVOICE).Editable(false);
                  })
              .PageSize(8)
              .Read(read => read.Action("GetOpenInvoices", "Maint", new { cust = Request.QueryString["cust"] }))
          )
            .Events(events => events.DataBound("dataBound"))
    )

    <script id="template" type="text/kendo-tmpl">
        @(Html.Kendo().Grid<CustomerComments>()
                .Name("grid_#=INVOICE#") // template expression, to be evaluated in the master context
                .Columns(columns =>
                {
                    columns.Bound(o => o.INVOICE).Width(15);
                    columns.Bound(o => o.Comment).Width(40);
                })
                .DataSource(dataSource => dataSource
                    .Ajax()
                    .Model(model =>
                                {
                                    model.Id(o => o.INVOICE);
                                    model.Field(o => o.INVOICE).Editable(false);
                                })
                    .PageSize(10)
                            .Read(read => read.Action("GetCustomerComments", "Maint", new { Id = "#=INVOICE#" }))
                )
                .Pageable()
                .Sortable()
                .ToClientTemplate()
        )
    </script>

    <script type="text/javascript">

        function dataBound() {
            this.expandRow(this.tbody.find("tr.k-master-row").first());
        }

    Controller method:

    public ActionResult GetCustomerComments([DataSourceRequest] DataSourceRequest request, string Id)
            {

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

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

  2. Gaurav
    Gaurav avatar
    14 posts
    Member since:
    Nov 2014

    Posted 21 Jun in reply to Gaurav Link to this post

    I am not using entity framework. For both grids calling custom stored procedures.
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 23 Jun Link to this post

    Hi Gaurav,

    There should be no problems if the ID field is a string value, because you are passing it as a custom parameter to the Read method. As you can see in the following online example, you have almost exactly the same setup for the hierarchy, except for the column with the checkbox:
    Currently, the only thing that I could suggest is to see if there are any JavaScript errors present on the page. If no errors occur, can you elaborate if the Read method does not fire if you expand different rows?

    Looking forward to your reply.


    Regards,
    Konstantin Dikov
    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
  5. Gaurav
    Gaurav avatar
    14 posts
    Member since:
    Nov 2014

    Posted 23 Jun in reply to Konstantin Dikov Link to this post

    There is no JavaScript error.

    It renders the child grid but nothing in body so no data.

    I removed the checkbox still it doesn't work.

    I am calling the stored procedure based on Invoice string which I am trying to pass using invoices = "#=INVOICE#" but the problem controller is not getting called.

    I see div Id is getting invoice value:

    <div class="k-widget k-grid" id="Grid_F300003787            ">

     

  6. Gaurav
    Gaurav avatar
    14 posts
    Member since:
    Nov 2014

    Posted 23 Jun in reply to Gaurav Link to this post

    It is working. Thank you for your help.
Back to Top
UI for ASP.NET MVC is VS 2017 Ready