0
我使用LLBLGen適配器模型返回結果。使用斷點是因爲我無法讓他們填充劍道網格,我可以看到他們都回來了。不過,我只需要返回具有昨天和之前日期屬性的結果。我並不熟悉使用kendo網格和LLBL適配器。其他大多數示例都使用實體框架。這是我到目前爲止。沒有錯誤消息,因爲我被困在如何設置過濾器?如何返回昨天和之前日期的結果
控制器
public ActionResult BundleStatus()
{
return View();
}
[HttpPost]
public ActionResult BundleStatusRead([DataSourceRequest] DataSourceRequest request)
{
var span = DateTime.Today.AddDays(-1);
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>
@(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))
.Selectable(selectable => selectable
.Mode(GridSelectionMode.Multiple)
.Type(GridSelectionType.Cell))
//.Events(events => events.Change("onChange").Sync("sync_handler")))
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("BundleStatusRead", "BundleStatus"))
//.Update(update => update.Action("EditingInline_Update", "Grid"))
)
)
更新控制器
public ActionResult BundleStatusRead([DataSourceRequest] DataSourceRequest request)
{
var span = DateTime.Today.AddDays(-1);
DataAccessAdapter adapter = new DataAccessAdapter();
EntityCollection allBundles = new EntityCollection(new CarrierBundleEntityFactory());
RelationPredicateBucket filter = new RelationPredicateBucket(CarrierBundleFields.Date == span);
adapter.FetchEntityCollection(allBundles, filter);
var results = allBundles;
return Json(results.ToDataSourceResult(request));
它不返回任何結果?這是我看到當我打開var結果LLBL的斷點枚舉沒有結果
它確實讓我進了一步。我認爲?看看我的編輯 – user3750212
如果沒有數據庫中的數據與昨天的日期,這將是正確的迴應。正確?我如何設置它,以便它在昨天和之前? – user3750212
用可能的解決方案更新答案。 –