This is a migrated thread and some comments may be shown as answers.
.NET Core Grid - ClientDetailTemplate Issue
7 Answers 12 Views
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 02 Apr 2021, 09:34 AM

Hi there,

I'm having an issue getting the grid with client detail template to work.

<div class="row mt-3 mb-2">
    <div class="form-group col-md-12 ">
        @(Html.Kendo().Grid(Model)
            .Name("ConditionAssessmentGrid")
            .Columns(columns =>
            {
                columns.Bound(p => p.ConditionAssessmentYear);
                columns.Bound(p => p.ConditionAssessmentId).Title("Actions").Width(100)
                    .ClientTemplate("<div class='btn-group grid-commands' role='group'>" +
                        "<a href='/Sites/ConditionAssessment/ConditionAssessment/Summary/#=ConditionAssessmentId#' class='btn btn-primary btn-sm mr-2'><i class='fas fa-eye'></i> View</a>");
            })
            .Sortable()
            .ClientDetailTemplateId("conditionassessmentemplate")
            .NoRecords(n => n.Template("<span class='mt-3 mb-3 col-md-12 text-left'>No data exists</span>"))
            .Pageable(p => p.Enabled(false))
            .DataSource(dataSource => dataSource
                .Ajax()
                .ServerOperation(false)
            )
        )
 
        @Html.AntiForgeryToken()
 
        <script id="conditionassessmentemplate" type="text/kendo-tmpl">
 
            @(Html.Kendo().Grid<ProtectedSites.ViewModel.ConditionAssessment.ConditionAssessmentGridViewModel>()
                 .Name("grid_#=ConditionAssessmentId#")
                 .Columns(columns =>
                 {
                     columns.Bound(p => p.FeatureInstance.FeatureName).Title("Feature");
                     columns.Bound(p => p.DateCreated).Title("Date created").Format("{0:dd/MM/yyyy}");
                     columns.Bound(p => p.CreatedUser).Title("Created by");
                     columns.Bound(p => p.LatestMonitoringDate).Format("{0:dd/MM/yyyy}").Title("Latest monitoring date");
                     columns.Bound(p => p.LatestMonitoringLevelOneResult).Title("Condition assessment 1");
                     columns.Bound(p => p.LatestMonitoringLevelTwoResult).Title("Condition assessment 2");
                 })
                 .DataSource(dataSource => dataSource
                    .Ajax()
                    .PageSize(5)
                    .Read(read => read.Action("GetFeatureInstances", "ConditionAssessment", new { siteid = ViewContext.RouteData.Values["SiteId"], conditionAssessmentId = "#=ConditionAssessmentId#" }))
                )
                .Pageable()
                .Sortable()
                .ToClientTemplate()
            )
        </script>
 
    </div>
</div>

 

My Parent grid model and child grid model both have a property named ConditionAssessmentId. However, when expanding the detail template, the read action always fails with the following error:

Uncaught ReferenceError: conditionassessmentid is not defined
    at Object.eval [as tmpl0] (eval at compile (kendo.all.js:234), <anonymous>:3:1645)
    at Object.eval (eval at compile (kendo.all.js:234), <anonymous>:3:185)
    at proxy (jquery.js:10771)
    at init._toggleDetails (kendo.all.js:69238)
    at HTMLAnchorElement.<anonymous> (kendo.all.js:69226)
    at HTMLTableElement.dispatch (jquery.js:5429)
    at HTMLTableElement.elemData.handle (jquery.js:5233)

 

I do note that it does correctly resolve the same binding expression in the Name property of the child grid, just not for the Read event.

Am I doing something obvious wrong here? I've referred to your DetailTemplate example and can't see anything I am doing differently.

Thanks,

Paul

7 Answers, 1 is accepted

Sort by
0
Georgi Denchev
Telerik team
answered on 07 Apr 2021, 08:58 AM

Hi, Paul,

Thank you for the provided code snippets.

The configuration seems to be correct, what I am noticing is that the error is for a property named "conditionassessmentid" all in lowercase characters which leads me to believe that it might be a serialization problem.

Check the following section of the documentation:

https://docs.telerik.com/aspnet-core/compatibility/json-serialization

Is the ConfigureServices method setup correct?

Best Regards,
Georgi Denchev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Paul
Top achievements
Rank 1
answered on 08 Apr 2021, 08:41 AM

Hi Georgi,

We didn't quite have the same code in Startup - I've made this the same now as the following code block and the issue persists:

public void ConfigureServices(IServiceCollection services)
{
    ...
    services
            .AddControllersWithViews()
            .AddJsonOptions(options =>
                options.JsonSerializerOptions.PropertyNamingPolicy = null);
 
    // Add the Kendo UI services to the services container.
    services.AddKendo();
}

 

Any ideas what I could try next?

Thanks,

Paul

0
Georgi Denchev
Telerik team
answered on 08 Apr 2021, 11:11 AM

Hi, Paul,

Would it be possible for you to prepare a small sample project where the issue is reproduced and attach it here? I'll debug it locally and return back with my findings and possible solution.

Best Regards,
Georgi Denchev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Paul
Top achievements
Rank 1
answered on 08 Apr 2021, 11:16 AM

Probably not to be honest - it would be quicker to rework the screen to not use the client template

Thanks anyway

0
Georgi Denchev
Telerik team
answered on 13 Apr 2021, 07:34 AM

Hello, Paul,

I am sorry that the issue was not resolved.

I'll try to look for other possible reasons as to why the problem occurs, however I cannot promise I'll be able to find anything without being able to examine the project myself. The provided setup in this thread is correct, so the issue is coming from somewhere else.

I'll keep you updated of any new discoveries.

Best Regards,
Georgi Denchev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Paul
Top achievements
Rank 1
answered on 13 Apr 2021, 08:18 AM

Thanks - apologies but I don't have the time to set up a demo project at present.

I will be looking again at this issue later in the week, will try setting up a new project from scratch and seeing if I can get the issue to reoccur - if so I will come back with any findings.

Thanks

Paul

0
Georgi Denchev
Telerik team
answered on 15 Apr 2021, 02:35 PM

Hello, Paul,

Thank you for your cooperation. Let me know if further assistance is required once you have more information, I'd be glad to help.

I'll close the ticket for now, however replying back in the thread will automatically reopen it and we will be able to continue our discussion.

Best Regards,
Georgi Denchev
Progress Telerik

Тhe web is about to get a bit better! 

The Progress Hack-For-Good Challenge has started. Learn how to enter and make the web a worthier place: https://progress-worthyweb.devpost.com.

Tags
Grid
Asked by
Paul
Top achievements
Rank 1
Answers by
Georgi Denchev
Telerik team
Paul
Top achievements
Rank 1
Share this question
or