ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
Grid - Action column with Ajax.ActionLink
Title:
B
I
{code}
?
Is it possible to use @Ajax.ActionLink in a Action Column ? do you have a sample ? I would like to add a EDIT column : @model EditBtn @Ajax.ActionLink("Edit", "Edit", "Company", new AjaxOptions { InsertionMode = InsertionMode.Replace, UpdateTargetId = "page-wrapper"}, new { id = Model.Id.ToString()}) this action have to call /Company/Edit?id=xx but thi is my firebug.. <td> <div class="awe-il"><a class="btn" id="4818" href="/CompanyGrid/Edit?Length=7" data-ajax-update="#page-wrapper" data-ajax-mode="replace" data-ajax="true">Edit</a> </div> </td> CompanyGrid is the name of the grid not the controller
Save Changes
Cancel
mtugnoli
asked at 21 Jan 2014
Answers
B
I
{code}
?
the closest sample we have for this is here: https://demo.aspnetawesome.com/GridDemo/CustomFormat (last 2 columns) you could do it like this: <% var ef2 = Ajax.ActionLink("edit2", "Edit", new {Id = ".Id"}, new AjaxOptions { InsertionMode = InsertionMode.Replace, UpdateTargetId = "t1" }).ToHtmlString(); %> <div id='t1'></div> ... new Column{ClientFormat = ef2, Width = 50} --- or your way by having a view in shared and rendering it for each cell: <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<AwesomeMvcDemo.Models.Purchase>" %> <%:Ajax.ActionLink("Edit3", "Edit", "PurchasesCrudDemo", new {Model.Id} ,new AjaxOptions{ InsertionMode = InsertionMode.Replace, UpdateTargetId = "t1"}) %> in grid action: return Json(new GridModelBuilder<Purchase>(list.OrderByDescending(o => o.Id).AsQueryable(), g) { Map = o => new { o.Customer, o.Date, o.Id, o.Product, o.Quantity, Edb = this.RenderView("editb", o) } }.Build()); in the view: new Column{ClientFormat = ".Edb"} --- in your case you used a different definition of the helper than the one you intended, so you need to switch places your last 2 parameters useful hint use Ctrl+Shift+Space in VS when inside ( )
Save Changes
Cancel
Omu
answered at 21 Jan 2014
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK