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

Custom Grid Command does not have Action Definition

3 Answers 267 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Deon van Staden
Top achievements
Rank 1
Deon van Staden asked on 22 Jun 2016, 09:01 AM

Hi,

I am new to Kendo and are trying to add a custom command to a grid.
I have been going over examples and this forum and found multiple examples that has the following:

columns.Command(command =>
{
     command.Custom("Details").Text("Show Details").Action("Details", "Billing");
});

 

When I try to use this, I get the following error:
'GridCustomActionCommandBuilder<myModel>' does not contain a definition for 'Action' and the best extension method overload 'UrlHelperExtensions.Action(IUrlHelper, string, object)' requires a receiver of type 'IUrlHelper'

 

I then tried this example from http://docs.telerik.com/kendo-ui/aspnet-mvc/helpers/grid/configuration:

columns.Template(@<text>@Html.ActionLink("Edit", "Home", new { id = item.ProductID })</text>);

But get this error:
Cannot convert lambda expression to type 'string' because it is not a delegate type

 

Please can someone please help me with this.

I am using existing samples but don't know what is wrong.

Thank you

3 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 24 Jun 2016, 04:50 AM
Hello Deon,

You will need to pass the correct count of arguments - 3 or 5:
http://stackoverflow.com/questions/316889/asp-net-mvc-passing-an-id-in-an-actionlink-to-the-controller

For example:
Copy Code
columns.Template(@<text></text>).ClientTemplate(@Html.ActionLink("Home","Index", "Home", new {id = "#=ProductCategoryId#"},null).ToHtmlString());
Or:
Copy Code
@Html.ActionLink("Home","Index", new {id = "#=ProductCategoryId#"}

You can also check these threads:
http://www.telerik.com/forums/kendo-mvc-grid-actionlink-column
http://www.telerik.com/forums/html-actionlink-and-clienttemplate
http://stackoverflow.com/questions/27168870/mvc-kendo-grid-hyperlink-column


I hope this will prove helpful.

Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Deon van Staden
Top achievements
Rank 1
answered on 25 Jun 2016, 10:50 AM

Thank you for the reply.

However, In trying your first example, I still have the same error result:

columns.Template(@<text></text>).ClientTemplate(@Html.ActionLink("Home","Index""Home"new {id ="#=ProductCategoryId#"},null).ToHtmlString());

It looks like whenever I have @<text></text>, get the following error:

Cannot convert lambda expression to type 'string' because it is not a delegate

Below is my code as it currently is:

@(Html.Kendo().Grid<OrganisationEmployeesViewModel>()
    .Name("grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.EmployeeID).Visible(false);
        columns.Bound(p => p.EmployeeNumber).Filterable(false);
        columns.Bound(p => p.Surname);
        columns.Bound(p => p.Position);
        columns.Template(@<text></text>).ClientTemplate(@Html.ActionLink("Home","Index", "Home", new {id = "#=EmployeeID#"},null).ToHtmlString());
    })
    .Pageable()
    .Sortable()
    .Scrollable()
    .Filterable()
    .HtmlAttributes(new { style = "height:550px;" })
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(20)
        .Read(read => read.Action("Employees_Read""Organisations"))
        .Create(create => create.Action("OrganisationCreate", "Employees", new { OrganisationID = @Model.OrganisationID.Value }))
     )
     .Deferred()
)

 

Thank you.

 

0
Eyup
Telerik team
answered on 29 Jun 2016, 06:22 AM
Hello Deon,

In this case, could you please try to define the ActionLink within the server template of a Bound or Template column and see whether this resolves the issue? Please check the following specific section for a reference:
http://docs.telerik.com/kendo-ui/aspnet-mvc/helpers/grid/faq#how-to-use-action-links

If the issue remains, we will prepare a sample runnable web site and send it to you to demonstrate both of the suggested approaches.

Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Deon van Staden
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Deon van Staden
Top achievements
Rank 1
Share this question
or