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

Template column in grid

3 Answers 938 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Cornel
Top achievements
Rank 1
Cornel asked on 30 Nov 2017, 04:38 PM

Hi,

In Kendo for Asp.Net (Not Core) I was using to have something like:

c.Template(@<text></text>).ClientTemplate("<a ...... ></a>")

And in ClientTemplate I had an Url.Action.

 

Now, in Asp.Net Core I cannot do this, as the Template property was changed. If I put the same thing I will have the error: Cannot convert lambda expression to type 'string' because it is not a delegate type.

 

Could you please help me to find a solution?

Thanks,

Cornel.

3 Answers, 1 is accepted

Sort by
0
Cornel
Top achievements
Rank 1
answered on 01 Dec 2017, 08:23 AM

Finally I did like this:

 

c.Bound("").ClientTemplate(@Html.ActionLink(...).ToHtmlString())

 

Where ToHtmlString() is an extension for IHtmlContent class. 

And now it works!

Thanks,

Cornel.

 

0
Martin
Top achievements
Rank 1
answered on 09 Apr 2018, 11:23 PM

In which version did you achieve this, netcore 2.0?. How did you access the .ToHtmlString() extension?

Thanks, 

Martin

0
Cornel
Top achievements
Rank 1
answered on 10 Apr 2018, 07:19 AM

Hi Martin,

It's AspNetCore version 2.0.2. And this is the implementation of the .ToHtmlString() extension:

 

public static string ToHtmlString(this IHtmlContent content)
{
            var writer = new System.IO.StringWriter();
            content.WriteTo(writer, System.Text.Encodings.Web.HtmlEncoder.Default);
            return writer.ToString();
}

 

Regards,

Cornel.

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