【问题标题】:What does "productService" mean in Kendo UI Grid/Inline editingKendo UI Grid/Inline 编辑中的“productService”是什么意思
【发布时间】:2014-03-18 03:39:50
【问题描述】:

当我阅读代码行时,我正在尝试使用 Kendo UI 创建一个 DataGrid:

private ProductService productService;

    public GridController()
    {
        productService = new ProductService(new SampleEntities());
    }

    protected override void Dispose(bool disposing)
    {
        productService.Dispose();

        base.Dispose(disposing);
    }

我不知道productService 是什么?谁能向我解释它来自哪里以及它在Controller 中是如何工作的?仅供参考link。非常感谢!

【问题讨论】:

    标签: jquery asp.net-mvc-4 c#-4.0 kendo-grid


    【解决方案1】:

    不要对此感到困惑……它只是一个示例代码。

    对于此示例网格 CustomerViewModel 绑定到网格..

    **************网格********

     @(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.CustomerViewModel>()
            .Name("grid")
            .Columns(columns =>
            {
                columns.Bound(c => c.ContactName).Width(140);
                columns.Bound(c => c.ContactTitle).Width(190);
                columns.Bound(c => c.CompanyName);
                columns.Bound(c => c.Country).Width(110);
            })
            .HtmlAttributes(new { style = "height: 380px;" })
            .Scrollable()
            .Groupable()
            .Sortable()
            .Pageable(pageable => pageable
                .Refresh(true)
                .PageSizes(true)
                .ButtonCount(5))
            .DataSource(dataSource => dataSource
                .Ajax()
                .Read(read => read.Action("Customers_Read", "Grid"))
            )
        )
    

    ********控制器功能****

    public ActionResult Customers_Read([DataSourceRequest]DataSourceRequest request)
            {
                return Json(GetCustomers().ToDataSourceResult(request));
            }
    
            private static IEnumerable<CustomerViewModel> GetCustomers()
            {
                var northwind = new SampleEntities();
                return northwind.Customers.Select(customer => new CustomerViewModel
                {
                    CustomerID = customer.CustomerID,
                    CompanyName = customer.CompanyName,
                    ContactName = customer.ContactName,
                    ContactTitle = customer.ContactTitle,
                    Address = customer.Address,
                    City = customer.City,
                    Region = customer.Region,
                    PostalCode = customer.PostalCode,
                    Country = customer.Country,
                    Phone = customer.Phone,
                    Fax = customer.Fax,
                    Bool = customer.Bool
                });
            }
    

    【讨论】:

    • 感谢您提供示例。我和范先生有同样的问题。此外,该站点还提供了另一个示例:telerikhelper.net/2014/01/06/…
    • 确保包括:使用 Kendo.Mvc.Extensions;对于 [DataSourceRequest]
    猜你喜欢
    • 2014-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-02
    • 2021-12-19
    • 1970-01-01
    相关资源
    最近更新 更多