This question is locked. New answers and comments are not allowed.
In the mvc grid, is is possible to create an extra command button to do a custom action? I'd like to add a button 'Edit' which doesn't edit inline (like the default command), but redirects the user to another view in which an edit form is shown.
4 Answers, 1 is accepted
0
Hello Datamex,
server template:
More information about column templates can be found in our help documentation.
Rosen
the Telerik team
In order to achieve the desired functionality, you may use a template column which contains a link.
client template:
columns.Bound(c => c.CustomerID).ClientTemplate(Html.ActionLink("Click Me", "Edit", "Customer", new { CustomerID = "<#= CustomerID #>" }, null).ToHtmlString());server template:
columns.Bound(c => c.CustomerID).Template(c => { %> <%=Html.ActionLink("Click Me", "Edit", "Customer", new { c.CustomerID }, null)%> <% })More information about column templates can be found in our help documentation.
Rosen
the Telerik team
0
Datamex
Top achievements
Rank 2
answered on 28 Mar 2011, 04:15 PM
Thanks, but that would render a link right, not a button?
0
Hi Datamex,
Rosen
the Telerik team
Generally speaking the button html element will do a post request, thus a form element will be needed or you will need to handle the click event through javascript and navigate to the new page manually. Therefore, the easiest way to do a GET request and have a button like look is to style the anchor html element. You can take a look at such approach in this demo for example, where the select button is an anchor element to which is applied t-button css class, thus it is styled to look like a button.
Regards,Rosen
the Telerik team
0
Datamex
Top achievements
Rank 2
answered on 29 Mar 2011, 08:25 AM
Hmmm, I will try that. This is the kind of the reason why I'm still not so sure about MVC. Trivial things like this, just putting a button inside a grid, seem to be a lot harder then they are in just regular ASP.NET. Is it me not understanding the technique, or is it just the way MVC rolls...