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

GridBoundColumnBuilder<MyModel>' does not contain a definition for 'Template'

3 Answers 37 Views
Grid
This is a migrated thread and some comments may be shown as answers.
T
Top achievements
Rank 1
T asked on 05 Feb 2021, 05:26 PM

I have a working server-bound grid. I'm trying to add a server-bound template column based on the following snippet from here.

 

columns.Bound(p => p.ProductName).Template(@<text>
    @if(@item.ProductName != null){
         @item.ProductName
    } else {
        "No data"
    }
    </text>
);

 

 

The ".Template" method generates the error:

Error CS1061 'GridBoundColumnBuilder<MyModel>' does not contain a definition for 'Template' and no accessible extension method 'Template' accepting a first argument of type 'GridBoundColumnBuilder<MyModel>' could be found (are you missing a using directive or an assembly reference?)

These lines are in my _ViewImports.cshtml:

@addTagHelper *, Kendo.Mvc
@using Kendo.Mvc.UI

Using Telerik.UI.for.AspNet.Core 2020.3.915

https://demos.telerik.com/aspnet-mvc/grid/serverrowtemplate

I have not yet found a solution after looking at many links. Am I really missing a using?

(And for the record, the New Thread editor for these forums is shameful. The standard Windows undo/redo/selection do not work in Chrome and poor/lack of formatting options significantly limit what I'm trying to convey.)

3 Answers, 1 is accepted

Sort by
0
Anton Mironov
Telerik team
answered on 09 Feb 2021, 12:58 PM

Hello,

Thank you for the code snippet and details provided.

In this case, I would recommend double-checking the ~Views/web.config file for the following row:

<namespaces>
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Routing" />
    <add namespace="Kendo.Mvc.UI" />
</namespaces>
If the config file is ok, follow the steps from the following article:

Let me know if the steps above resolve the issue. If the issue persists - the fastest route to getting you up and running is if you could provide a runnable, isolated, sample project. Examining this project will let us replicate the issue locally and further troubleshoot it.

Furthermore, I created a sample MVC project(attached) that includes all the needed dependencies. Use it as a template, or as you decide for the needs of your application.

Looking forward to hearing back from you.

Kind Regards,
Anton Mironov
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/.

0
T
Top achievements
Rank 1
answered on 09 Feb 2021, 02:53 PM

The grid is completely working without the template column, and the web app is on .Net Core 3.1 so does not have a web.config. From the csproj file, and this is the same version listed in the Solution Explorer dependencies:

 

<PackageReference Include="Telerik.UI.for.AspNet.Core" Version="2020.3.915" />

 

Unfortunately I do not have time to create a mock Ultimately, we'd just like more documentation: a snippet of the Template extension method. This was as far as we got:

public static class TelerikExtensions
{
     public static GridBoundColumnBuilder<T> Template<T>(this GridBoundColumnBuilder<T> item, Func<T, HelperResult> template) where T : class
{
 return item;
}

}

 

We could not connect the dots between this and the blog post referenced in the existing Telerik documentation and have since moved to a client-side work around.

0
Anton Mironov
Telerik team
answered on 11 Feb 2021, 01:15 PM

Hello,

Thank you for the additional details provided.

In this case, I would recommend using one of the following approaches:

I hope this information helps. Let me know if the first approach is achieving the desired behavior.

 

Best Regards,
Anton Mironov
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
T
Top achievements
Rank 1
Answers by
Anton Mironov
Telerik team
T
Top achievements
Rank 1
Share this question
or