Can't get custom command button to invoke an action in my controller.

15 posts, 1 answers
  1. Mike
    Mike avatar
    9 posts
    Member since:
    Aug 2012

    Posted 01 Sep 2012 Link to this post

    Hello,

    I've added a custom command, "Details", to the rows in my grid so a user can view the details about the row.  When clicked, I want it to access the Details action in my HomeController.  However, when I build my solution, I receive the following error message:

    "Custom command routes is available only for server binding."

    Can someone please tell me how I can correct this issue?  My ulitimate goal is to create custom command buttons for Add, Edit, Delete, and Details, so my existing Views will be presented, rather than using the inline editing.  I need to create these custom buttons because the default command buttons don't seem to permit routing to my Views.  Anyway, I would appreciate your help.

    Thanks,
    Mike

          .Columns(columns =>
          {
              columns.Command(p => { p.Custom("ViewDetails").Action("Details", "Home").Text("Details"); }).Width(160);
              columns.Bound(p => p.CustomerId)
          })
  2. Answer
    Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 05 Sep 2012 Link to this post

    Hi Mike,

    As the messages describes the ActionLink command is available only for Server binding. If you want to create a buttom with which points to a different view when using Ajax binding you can use a template column with a hyperlink inside of it.
    columns.Template(@<text></text>).ClientTemplate("<a href='"+Url.Action("Edit","Home")+"/#=PersonID#'>Edit</a>");



    Kind Regards,
    Petur Subev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Paul
    Paul avatar
    8 posts
    Member since:
    Jan 2012

    Posted 14 Jul 2014 in reply to Petur Subev Link to this post

    Why is that not shown as example here then

    http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-grid-custom-commands.html#AjaxCommand

    Very frustrating looking to the documentation for any sort of answers or guidance.
  5. Neer
    Neer avatar
    3 posts
    Member since:
    Aug 2011

    Posted 03 Sep 2014 in reply to Paul Link to this post

    I agree!!! I only found this forum post, because I Googled "custom command routes is available only for server binding."
  6. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2153 posts

    Posted 04 Sep 2014 Link to this post

    Hello guys,


    The topic is covered in the following FAQ section of the documentation.

    Have a great day!

    Regards,
    Dimiter Madjarov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  7. James
    James avatar
    17 posts
    Member since:
    Sep 2014

    Posted 30 Dec 2014 Link to this post

    I can not add the @<text></text> in the template or I get a nesting error:
    Error 1 Inline markup blocks (@<p>Content</p>) cannot be nested.  Only one level of inline markup is allowed.  How can the Url.Action be drawn in an Ajax loaded child grid?
  8. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 02 Jan 2015 Link to this post

    Hello,

    You can try this:

    .ClientTemplate("<a href='" + Url.Action("Index", "Home") + "'>Home</a>");


    Regards,
    Atanas Korchev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  9. Jim
    Jim avatar
    18 posts
    Member since:
    Dec 2014

    Posted 01 Feb 2015 in reply to Atanas Korchev Link to this post

    hey great help, but what if I want to put a command button instead of an actionlink?  basically i want a command button that will call the Edit controller action.
  10. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 02 Feb 2015 Link to this post

    Hello,

    You should use a Command column to get the built-in edit command:

    columns.Command(commands => commands.Edit());


    Regards,
    Atanas Korchev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  11. srinivasa rao
    srinivasa rao avatar
    1 posts
    Member since:
    Dec 2015

    Posted 18 Dec 2015 in reply to Petur Subev Link to this post

    I am new to KendoUI Grid Can let me know From where PersonId Came from.

    I am trying but Parameter is not passing to the action method.

    Could you help me no this.

  12. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2153 posts

    Posted 23 Dec 2015 Link to this post

    Hello Srinivasa,

    PersonID refers to the id property from the Grid model and is appended to the link in the template.

    Regards,
    Dimiter Madjarov
    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
  13. Deon van Staden
    Deon van Staden avatar
    5 posts
    Member since:
    Sep 2005

    Posted 22 Jun in reply to Dimiter Madjarov Link to this post

    I am trying to use the example above:

    columns.Template(@<text></text>).ClientTemplate("<a href='"+Url.Action("Edit","Home")+"/#=PersonID#'>Edit</a>");

    but keep on receiving the following error whenever I have @<text></text>

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

    Why is it that I cannot use @<text> in my Razor code to explicitly define this content?

  14. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2153 posts

    Posted 23 Jun Link to this post

    Hello Deon van Staden,

    The provided sample code looks correct. I assume it is not the reason for the mentioned error.

    Regards,
    Dimiter Madjarov
    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
  15. Matthew
    Matthew avatar
    2 posts
    Member since:
    May 2016

    Posted 10 Nov in reply to Atanas Korchev Link to this post

    How does this help I still get the same error
  16. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2153 posts

    Posted 14 Nov Link to this post

    Hello Matthew,

    Please provide further details about the Grid configuration on your end and if possible send us an isolated runnable example, so we could inspect it locally and provide assistance.

    Regards,
    Dimiter Madjarov
    Telerik by Progress
    Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
Back to Top
UI for ASP.NET MVC is VS 2017 Ready