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

Custom grid html helper

7 Answers 188 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Casiana
Top achievements
Rank 1
Casiana asked on 10 Mar 2017, 06:12 PM

Hello,

I want to create a html helper for grid in asp.net core application using code from this example Define a custom Html.Kendo extension helper.

But HtmlHelper class not found. What am I doing wrong?

7 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 15 Mar 2017, 04:07 PM
Hi Casiana,

You could try to replace the HtmlHelper with the interface IHtmlHelper:
Hope this helps.


Regards,
Konstantin Dikov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Casiana
Top achievements
Rank 1
answered on 16 Mar 2017, 11:34 AM

Hello Konstantin,

Thank you for your help.

I want to create a custom grid with GridFilterMode.Row, and set each column filter operator display text and "NO DATA FOUND" message. I have not found a way to change them, can you help me?

0
Konstantin Dikov
Telerik team
answered on 21 Mar 2017, 11:28 AM
Hi Casiana,

The requirement that you have should be available out of the box and you could check our online demo for the Row filtering:
If you have something different in mind, please provide additional information about the requirement.


Regards,
Konstantin Dikov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Luke
Top achievements
Rank 1
answered on 20 Mar 2018, 07:25 PM

Hi I'm currently trying to implment this, but I'm getting an error: 'IHtmlHelper' does not contain a definition for 'Kendo' and no extension method 'Kendo' accepting a first argument of type 'IHtmlHelper' could be found. Any help would be appreciated.

Here is my Extensions file:

using Kendo.Mvc.UI;
using Microsoft.AspNetCore.Mvc.Rendering;
 
namespace MantleMapperDotNet.WebCore.Helpers
{
    public static class HtmlExtensions
    {
 
        public static Kendo.Mvc.UI.Fluent.GridBuilder<T> MyGrid<T>(this IHtmlHelper helper, string name)
            where T : class
        {
            return helper.Kendo().Grid<T>();
        }
    }
}

0
Konstantin Dikov
Telerik team
answered on 23 Mar 2018, 01:39 PM
Hi Luke,

You could try to use the GridBuilder instead:
using Kendo.Mvc.Examples.Models;
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
using Kendo.Mvc.UI.Fluent;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
 
namespace MyNamespace
{
    public static class MyHtmlHelperExtensions
    {
        public static GridBuilder<T> MyKendoGrid<T>(this GridBuilder<T> helper, string name)
        where T : class
        {
            return helper
                .Name(name)
                .Groupable()
                .Pageable()
                .Sortable()
                .Scrollable()
                .Filterable()
                .Pageable();
        }
    }
}

Hope this helps.


Regards,
Konstantin Dikov
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Leo
Top achievements
Rank 1
answered on 10 Mar 2021, 09:12 PM

Currently migrating this project from .NET MVC 5.2.7 to .Net Core 3.1 and in that proces i'm having trouble to get this extension fixed. 

It is the exact same problem as Luke describes. The Kendo() method is not available on the IHtmlHelpers. I don;t know why, as far as ai can see all usings are in place. The suggestions from Constantin is different, it extends the GridBuidler, not the IHhtmlHelper. So all views have to change, while the method should be available to the IHhtmlHelper object. 
Anything changed since 2018? Or other suggestions?

0
Leo
Top achievements
Rank 1
answered on 10 Mar 2021, 09:15 PM
LoL just seconds after posting this my brain made some weird connection... i got it fixed. The signature should be different, kjujst add the <dynamic>

public static GridBuilder<T> MyKendoGrid<T>(this IHtmlHelper<dynamic> helper) where T : class 
Tags
Grid
Asked by
Casiana
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Casiana
Top achievements
Rank 1
Luke
Top achievements
Rank 1
Leo
Top achievements
Rank 1
Share this question
or