我被分配了通过LLBL适配器模型在页面加载时填充网格数据。我可以检索结果,因为我可以在设置断点时看到它们。我的任务的最终结果是从昨天和之前加载所有包,如果“IsSent”属性为False,那么我需要将其切换为True。我的问题是如何通过网格的初始加载?我尽可能多地关注了演示,但我无法让它发挥作用。
控制器
public ActionResult BundleStatusRead([DataSourceRequest] DataSourceRequest request)
{
DataAccessAdapter adapter = new DataAccessAdapter();
EntityCollection allBundles = new EntityCollection(new CarrierBundleEntityFactory());
adapter.FetchEntityCollection(allBundles, null);
var results = allBundles;
return Json(results.ToDataSourceResult(request));
}
查看
@{
ViewBag.Title = "BundleStatusGet";
}
<div id="clientsDb">
@(Html.Kendo().Grid<ZoomAudits.DAL.EntityClasses.CarrierBundleEntity>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(c => c.BundleId).Width(140);
columns.Bound(c => c.CarrierId).Width(190);
columns.Bound(c => c.Date);
columns.Bound(c => c.IsSent).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("BundleStatusRead", "BundleStatus"))
)
)
错误消息 错误1'ZoomAudits.DAL.HelperClasses.EntityCollection'不包含'ToDataSourceResult'的定义,并且没有扩展方法'ToDataSourceResult'接受类型'ZoomAudits.DAL.HelperClasses.EntityCollection'的第一个参数可以找到(你错过了吗?使用指令或程序集引用?)
答案 0 :(得分:2)
我错过了Kendo.Mvc.Extensions参考
using Kendo.Mvc.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ZoomAudits.DAL.DatabaseSpecific;
using ZoomAudits.DAL.EntityClasses;
using ZoomAudits.DAL.FactoryClasses;
using ZoomAudits.DAL.HelperClasses;
using Kendo.Mvc.Extensions;
using SD.LLBLGen.Pro.ORMSupportClasses;
using System.Web.Script.Serialization;