<h2>Load Summary</h2>
@(Html.Kendo().Grid<MyProject.Models.Invoice>()
.Name("grid")
.HtmlAttributes(new { style = "width: 100%" } )
.Columns(columns =>
{
columns.Template(@<text>@Html.ActionLink("Details", "Invoice", "Details", new { id = @item.InvoiceID })</text>)
.ClientTemplate("<a href='/Invoice/Details/#= InvoiceID#'>Details</a>").Width("5%");
columns.Bound(p => p.InvoiceNumber).Width("5%").Title("Load No.");
columns.Bound(p => p.BookDate).Format("{0:d}").Width("5%");
})
.DataSource(datasource => datasource
.Ajax()
.Read(read => read.Action("GetLoads", "Invoice"))
.Model(m => m.Id(model => model.InvoiceID))
)
.Pageable()
.Sortable()
.Filterable()
.Selectable(selectable => selectable
.Mode(GridSelectionMode.Single))
)
Here are my controller actions:
public ActionResult Index()
{
IEnumerable<Invoice> invoices = _db.Invoices.Where(p => p.SalesmanID == _salesmanId);
return View(invoices.ToList());
}
//
// GET: /Invoice/Details/5
public ActionResult Details(int id = 0)
{
Invoice invoice = _db.Invoices.Find(id);
if (invoice == null)
{
return HttpNotFound();
}
_routeValues = this.GridRouteValues();
InvoiceViewModel invoiceViewModel = Mapper.Map<Invoice, InvoiceViewModel>(invoice);
return View(invoiceViewModel);
}
[HttpPost]
public ActionResult Details(string btnSubmit)
{
return RedirectToAction("Index", _routeValues);
}
Thanks