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

Grid/Detail Grid will it work if Id is string

4 Answers 478 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gaurav
Top achievements
Rank 1
Gaurav asked on 21 Jun 2016, 10:10 PM

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));
        }

4 Answers, 1 is accepted

Sort by
0
Gaurav
Top achievements
Rank 1
answered on 21 Jun 2016, 10:25 PM
I am not using entity framework. For both grids calling custom stored procedures.
0
Konstantin Dikov
Telerik team
answered on 23 Jun 2016, 08:23 PM
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
0
Gaurav
Top achievements
Rank 1
answered on 23 Jun 2016, 09:23 PM

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            ">

 

0
Gaurav
Top achievements
Rank 1
answered on 23 Jun 2016, 10:05 PM
It is working. Thank you for your help.
Tags
Grid
Asked by
Gaurav
Top achievements
Rank 1
Answers by
Gaurav
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or