Custom Grid Command does not have Action Definition

4 posts, 0 answers
  1. Deon van Staden
    Deon van Staden avatar
    5 posts
    Member since:
    Sep 2005

    Posted 22 Jun Link to this post

    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

  2. Eyup
    Admin
    Eyup avatar
    3012 posts

    Posted 23 Jun Link to this post

    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
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Deon van Staden
    Deon van Staden avatar
    5 posts
    Member since:
    Sep 2005

    Posted 25 Jun in reply to Eyup Link to this post

    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.

     

  5. Eyup
    Admin
    Eyup avatar
    3012 posts

    Posted 29 Jun Link to this post

    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
Back to Top
UI for ASP.NET MVC is VS 2017 Ready