Hierarchy with asp.net core razor grid

1 Answer 226 Views
Grid
Deepthi
Top achievements
Rank 1
Deepthi asked on 06 Apr 2023, 04:07 PM | edited on 10 Apr 2023, 03:24 AM

I am trying to implement the Hierarchy with asp.net core razor grid. The child detail rows are not coming up. Can you please help me with this issue

@(Html.Kendo().Grid < Orders.Models.Case>
                                ().Name("grid")
                                //.Groupable()
                                .Sortable()
                                .Scrollable()
                                .Filterable()
                                 .ToolBar(t => t.Search())
                                 .Resizable(resize => resize.Columns(true))
                                //.ToolBar(x => x.Create())
                                .Columns(columns =>
                                {

                                    columns.Bound(column => column.EmpId).Stickable(true);
                                    columns.Bound(column => column.Name);
                                    columns.Bound(column => column.Type);

                                    //columns.Command(column =>
                                    //{
                                    //    column.Edit();
                                    //    column.Destroy();
                                    //}).Width(230);
                                })
                                .ToolBar(tools => tools.Excel()).Excel(excel => excel.FileName("cases.xlsx"))
                                .Excel(excel => excel.AllPages(true))
                                 .Reorderable(reorder => reorder.Rows(true).Columns(true))
                                .DataSource(ds => ds.Ajax()
                                .Read(r => r.Url("/Index?handler=Read").Data("forgeryToken"))
                                .ServerOperation(false)
                             
                                .PageSize(10)
                                )
                                .Pageable()
                                .Pageable(pageable => pageable.PageSizes(new int[] { 5, 10, 20, 100 }))
                                .ClientDetailTemplateId("template")
)

<script>
    function forgeryToken() {
        return kendo.antiForgeryTokens();
    }
</script>

<script id="template" type="text/kendo-tmpl">
            @(Html.Kendo().Grid<CobbJudicialRecordsSrch.Models.CaseOffenses>()
                    .Name("grid_#=CaseId#") // template expression, to be evaluated in the master context
                    .Columns(columns =>
                    {
                        columns.Bound(o => o.OrderId).Width(110);
                        columns.Bound(o => o.OrderDescription).Width(150);
                        columns.Bound(o => o.OrderName).Width(150);

                        //columns.Bound(o => o.Dispositon).ClientTemplate("\\#= ShipAddress \\#"); // escaped template expression, to be evaluated in the child/detail context
                        //columns.Bound(o => o.ShipName).Width(300);
                    })
                    .DataSource(dataSource => dataSource
                        .Ajax()
                        .PageSize(10)
                         .Read(read => read.Action("HierarchyBinding_Orders", "Grid", new { employeeID = "#=empId#" }))
                    )
                    .Pageable()
                    .Sortable()
                    .ToClientTemplate()
            )
</script>
<script>
    function dataBound() {
        this.expandRow(this.tbody.find("tr.k-master-row").first());
    }
</script>

 

 

1 Answer, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 11 Apr 2023, 06:40 AM

Hi Deepthi,

Thank you for reaching out and for taking the time and effort to share the relevant Grid configurations that are currently incorporated on your end.

Generally, with each POST request within a RazorPages Grid scenario, it is mandatory that an AntiForgeryToken is passed both for the parent and child Grid declarations. Thus, I would recommend attaching a .Data() handler for the child(detail) Grid as well:

.DataSource(source => source.Ajax()
     ...
     .Read(read => read.Action("HierarchyBinding_Orders", "Grid", new { employeeID = "#=empId#" }).Data("forgeryToken"))
)

For your convenience, I am attaching a runnable Razor Pages Hierarchy Grid example for you to review. If this does not help, could you please consider reciprocating the sporadic behavior within the sample and send it back for further examination?

I hope this helps.

Kind Regards,
Alexander
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Deepthi
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Share this question
or