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

Hierarchical Grid not able to access child grid

2 Answers 157 Views
Grid
This is a migrated thread and some comments may be shown as answers.
DHHS
Top achievements
Rank 1
DHHS asked on 28 Jul 2015, 01:39 PM

I have a hierarchical grid and a button on child grid which on click opens a window and there is a grid on that window. When on click of the button on child grid , i am trying to reload the grid on the window, but throwing an exception $(...).data(...).kendoGrid is undefined. upon all this, it has been working perfectly fine for one month and suddenly it is not fetching any rows. when i debugged it is throwing this exception. may i know what has changed suddenly even though i haven't changed anything on this page.

parent grid
 
  <div class="container-fluid">
        <div class="row">
            <div class="col-xs-18 col-md-12">
                @(Html.Kendo().Grid<BHEBS.Areas.Admin.Models.ContractModel.providers>()
        .Name("grid")
        .Columns(columns =>
        {
            //columns.Bound(p => p.Id).Filterable(false).Width(50);
            columns.Bound(p => p.ContractorType);
            columns.Bound(p => p.BHSISNum);
            columns.Bound(p => p.StartDate).Format("{0:MM/dd/yyyy}");
            columns.Bound(p => p.EndDate).Format("{0:MM/dd/yyyy}");
            columns.Bound(p => p.ContractorIsAlsoRegion);
            columns.Bound(p => p.ContractorName);
            columns.Bound(p => p.AddressBkNum);
            columns.Command(command => command.Custom("Remove").Text("Remove").SendDataKeys(true).Click("deleteClick").HtmlAttributes(new { @class = "k-button k-button-icontext k-grid-add k-primary" }));
 
        }).Events(e => e.DataBound("onDataBound"))
        .Pageable()
        .Sortable()
        .Scrollable()
        .Filterable()
        .Selectable()
        .ClientDetailTemplateId("template")
        .HtmlAttributes(new { style = "height:550px;" })
        .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(20)
        .Read(read => read.Action("Contractors_Read", "Contract").Data("additionalInfo"))
        )
 
        @*.ToolBar(toolbar =>
            {
                toolbar.Template(@<text>
                    <div class="toolbar">
                        <button class="k-button k-button-icontext k-grid-add k-primary" id="providerskendowindow">Add Providers</button>
 
                    </div>
                </text>);
            })*@
 
                )
            </div>
        </div>
    </div>
 
child grid
 
 <script id="template" type="text/kendo-tmpl">
        @(Html.Kendo().Grid<BHEBS.Areas.Admin.Models.ContractModel.serviceDetails>()
            .Name("grid_#=Id#")
            .Columns(columns =>
            {
                // columns.Bound(o => o.Id).Width(50);
                columns.Bound(o => o.ServiceId);
                columns.Bound(o => o.ServiceType);
                columns.Bound(o => o.AdultChild);
                columns.Bound(o => o.Qualifier);
                columns.Bound(o => o.CodeModifier);
                columns.Bound(o => o.ServiceModifier);
                columns.Bound(o => o.StartDate).Format("{0:MM/dd/yyyy}");
                columns.Bound(o => o.EndDate).Format("{0:MM/dd/yyyy}");
                columns.Command(command => command.Custom("Remove").SendDataKeys(true).Click("deleteClickServices"));
            }).Events(e => e.DataBound("onDataBoundServices"))
             .ToolBar(toolbar =>
{
    toolbar.Template(@<text>
        <div class="toolbar">
            <button class="k-button k-button-icontext k-grid-add k-primary" id="serviceskendowindow">Assign Services</button>
        </div>
    </text>);
})
                                        .DataSource(dataSource => dataSource
                                            .Ajax()
                                            .PageSize(10)
                                                          .Read(read => read.Action("Services_Read", "Contract", new { contractorId = "#=Id#", contractId = ViewBag.ContractService.Id }))
                                        )
 
 
                                        .Pageable()
                                        .Sortable()
                                        .ToClientTemplate()
 
        )
    </script>
 
window on click of button on child grid
 
    @(Html.Kendo().Window()
    .Name("servicewindow")
    .Title("Assign Services")
    .Content(@<text><div class="container-fluid">
            <div class="row">
                <div class="col-xs-18 col-md-12">
                    @(Html.Kendo().Grid<BHEBS.Areas.Admin.Models.ContractModel.serviceDetails>()
        .Name("gridServicesWindow")
        .Columns(columns =>
        {
            columns.Template(x => { }).HtmlAttributes(new { @class = "chkbox" }).ClientTemplate("<input type='checkbox' class='checkbox' id = 'chkBoxServices' />");
            columns.Bound(p => p.Id).Filterable(false).Width(50);
            columns.Bound(p => p.ServiceId);
            columns.Bound(p => p.ServiceType);
            columns.Bound(p => p.StartDate).Format("{0:MM/dd/yyyy}");
            columns.Bound(p => p.EndDate).Format("{0:MM/dd/yyyy}");
            columns.Bound(p => p.AdultChild);
        })
                .Pageable()
                .Sortable()
                .Scrollable()
                .Filterable()
                        .AutoBind(false)
                .Selectable(selectable => selectable.Mode(GridSelectionMode.Multiple))
                .HtmlAttributes(new { style = "height:350px;" })
                .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(20)
                                .Read(read => read.Action("GetAllServices_Read", "Contract").Data("additionalInfoAddServices{('#=Id#');}"))
                )
                    )
                    <button class="k-button close-buttonservices k-primary" style="bottom: 10px; ">Cancel</button>
                    <button class="k-button k-primary" id="addSelectedServices" style="bottom: 10px; ">Assign</button>
                </div>
 
            </div>
 
 
        </div></text>
            )
            .Draggable()
    .Resizable()
    .Width(800)
    .Modal(true)
    .Visible(false)
 
    )
 
on click of button on child grid
 
        $("#grid").on("click", "#serviceskendowindow", function(e){
            $("#servicewindow").data("kendoWindow").center().open();
            var grid = $("#grid").data("kendoGrid");
            var row= grid.dataItem($(e.target).closest(".k-detail-row").prev(".k-master-row"));
            addSelectedContractorService = row.Id;          
            $('#gridServicesWindow').data().kendoGrid.dataSource.read();
        });
 
 
        $("#gridServicesWindow").on("click", ".checkbox", function (e) {
            var checked = $(this).is(":checked");
            row = $(this).closest("tr");
            var grid = this;  // this is not even identifying here so changed to this line
           // var grid = $("#gridServicesWindow").data("kendoGrid");
            var model = grid.dataItem(row);
            checkedServiceIds[model.Id] = checked;
        });

2 Answers, 1 is accepted

Sort by
0
DHHS
Top achievements
Rank 1
answered on 28 Jul 2015, 02:42 PM
sorry attached the wrong file. Please find the attached file
0
DHHS
Top achievements
Rank 1
answered on 28 Jul 2015, 10:08 PM

Never mind. Found the issue and fixed.

 

Thanks,

Veena

Tags
Grid
Asked by
DHHS
Top achievements
Rank 1
Answers by
DHHS
Top achievements
Rank 1
Share this question
or