gpt4 book ai didi

jquery - Kendo UI网格/内联编辑中 "productService"是什么意思

转载 作者:行者123 更新时间:2023-12-01 04:49:41 25 4
gpt4 key购买 nike

当我阅读代码行时,我正在尝试使用 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 。非常感谢!

最佳答案

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

对于此示例,网格 CustomerViewModel 已绑定(bind)到网格..

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

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

******** Controller 功能****

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
});
}

关于jquery - Kendo UI网格/内联编辑中 "productService"是什么意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22469916/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com