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

2 grids based on 1st grid selected checkboxes ask stored procedure to populate 2nd grid

3 Answers 28 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, 09:55 PM

 I understand how to pass additional data as a parameter example I am doing this
.Read(read => read.Action("GetOpenInvoices", "Maint", new { cust = Request.QueryString["cust"] }))
Is it possible to have Parent/child  or grid/details grid to do without entity framework meaning asking custom stored procedures for the data?
I have a grid with Invoices. I want user to select multiple checkboxes  and then click the button and based on that 2nd grid gets populated.
or have a parent grid loaded and based on checkboxes (invoice# which is a string) I click ask stored procedure to get me corresponding comments.
Initially 2nd grid is empty.
If you have any example that will be great.
I want an example without entity framework.
Please reply if there is any easy solution.

Thank you,
Gaurav

3 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 23 Jun 2016, 03:13 PM

Hello Gaurav,

There is no need to use the entity framework on the server. In our examples it used with sample purposes since the entity framework is widespread in the .NET community. 

The Kendo UI Grid for ASP.NET MVC expects a JSON response from the server containing the data and it expects the response to have a specific structure. This is why we suggest using the ToDataSourceResult extension method. 

Please refer to the Ajax Binding article for a reference. 

Also 

Regards,
Boyan Dimitrov
Telerik
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
0
Gaurav
Top achievements
Rank 1
answered on 23 Jun 2016, 06:39 PM

How to fail the mvc controller on purpose and do nothing

Controller Method:

        public ActionResult GetCustomerComments([DataSourceRequest] DataSourceRequest request, string invoices)
        {
            if (invoices != "fail")
            {

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

            return Json(customer.ToDataSourceResult(request));
            }
            else
            {
                //do nothing
            }
        }

I am trying to upgrade the grid using ajax
        $.ajax({
            url: webManager.resolveUrl("~/maint/GetCustomerComments"),
            method: "POST",
            data: { invoices: invoicesList },
            success: function () {
                var grid = $('#CustomerCommentsGrid').data('kendoGrid');
                grid.dataSource.read();
                grid.refresh();
            },
            error: function () {
                alert('an error occurred');
            }

        });

But the problem is Grid is called again and I want to stop that.

     @(Html.Kendo().Grid<CustomerComments>()
      .Name("CustomerCommentsGrid")
      .Columns(columns =>
      {
          columns.Bound(i => i.INVOICE).Title("Invoice").Width(15);
          columns.Bound(i => i.Comment).Title("Comment").Width(40);

      }).Pageable(pageable => pageable
          .Refresh(true)
      )
      .Scrollable()
      .Sortable()
      .Filterable()
      .DataSource(dataSource => dataSource
          .Ajax().UseJniErrorHandler()
          .PageSize(10)
              .Read(read => read.Action("GetCustomerComments", "Maint", new { invoices = "fail" }))
      )
)

0
Gaurav
Top achievements
Rank 1
answered on 23 Jun 2016, 09:13 PM
I was able to solve my issue using following AJAX
$.ajax({ url: webManager.resolveUrl("~/maint/GetCustomerComments"), method: "POST", data: { invoices: invoicesList }, success: function (result) {var grid = $("#CustomerCommentsGrid").data("kendoGrid");var dataSource = new kendo.data.DataSource({ data: result.Data}); grid.setDataSource(dataSource); grid.dataSource.read();}, error: function () { alert('an error occurred');}});


Needed to know how to set datasource for the grid.
Tags
Grid
Asked by
Gaurav
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Gaurav
Top achievements
Rank 1
Share this question
or