【问题标题】:I am not able to bind data in telerik grid我无法在 Telerik 网格中绑定数据
【发布时间】:2012-11-02 14:43:06
【问题描述】:

我写的控制器如下:

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()
)

我的问题是,当我运行此应用程序时,数据未绑定,因此在网格中显示为空白。 请帮帮我。

【问题讨论】:

    标签: javascript telerik telerik-grid


    【解决方案1】:

    您是否尝试过在数据绑定中使用 .OperationMode(GridOperationMode.Client)?

    例子:

    .DataBinding(dataBinding => dataBinding.Ajax()
        .OperationMode(GridOperationMode.Client)
        .Select("SelectVessel", "Commodity")
     ) 
    

    您可以随时查看 online documentation from telerik 如有疑问。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-23
      • 2013-03-23
      • 2012-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多