我写的控制器如下:
public class CommodityController : Controller
{
public ActionResult Vessel()
{
return View();
}
[GridAction]
public ActionResult SelectVessel()
{
var query = _productServices.GetAllProducts().ToList();
var model = PreparedBasicProductModel(query);
return View(new GridModel(model));
}
}
我写了如下观点:
@using Telerik.Web.Mvc.UI;
@using Telerik.Web.Mvc;
@model List<VesselSelection.Models.Vessel.ProductModel>
@(Html.Telerik().Grid<VesselSelection.Models.Vessel.ProductModel>()
.Name("Grid")
.DataBinding(dataBinding => dataBinding.Ajax().Select("SelectVessel", "Commodity")
)
.DataKeys(keys => keys.Add(c => c.Id))
.Columns(columns =>
{
columns.Bound(c => c.Id).Title("Picture");
columns.Bound(c => c.Name).Title("Data");
columns.Bound(c => c.ProductPicture).Title("Command");
})
.ClientRowTemplate(grid => "<div class='employee-details'>" +
"<img class='t-widget' src='<#= ProductPicture #>' alt='<#= Name #>' title='<#= Name #>' />" +
"<dl>" +
"<dt>Weight:</dt><dd><#= Weight #></dd>" +
"<dt>Cost Price:</dt><dd><#= CostPrice #></dd>" +
"<dt>Vendor:</dt><dd><#= VendorName #></dd>" +
"<div class='commands'>" + grid.EditButton(null) + grid.DeleteButton(null) + "</div>" +
"</div>"
)
.Sortable()
.Editable(editing => editing.Mode(GridEditMode.PopUp))
.Scrollable(scrolling => scrolling.Height(500))
.Pageable()
)
我的问题是,当我运行此应用程序时,数据未绑定,因此在网格中显示为空白。请帮我。