绑定到大型数据库会返回空的DevExpress GridView

时间:2014-11-28 09:53:10

标签: asp.net-mvc gridview devexpress iqueryable

我读了一篇关于将DevExpress GridView绑定到大数据的article

使用常规列表实现,一切正常。现在,当我将它绑定到IQueryable时,我遇到了这个问题:绑定工作,也是分页,方法返回正确的数据集,但gridview中的所有行都是空的。

以下是它的外观:

picture

这是我的控制器代码。

[HttpPost]
public ActionResult PayrollGridPartial(PayrollModel model)
{
    model.PayrollList = PayrollService.Search(model.PayrollSearch);
    var list = model.PayrollList.Select(s => new { s.FIRSTNAME, s.PERSONID }).ToList();
    return View(model);
}

在临时检查 list 之后,很明显所有数据都按原样返回(列表中填充了数据)。

这是网格PartialView:

@model CT.ISVDV.WebUI.Models.PayrollModel

@using CT.ISVDV.DataObjects.Resources;

@{
    Layout = null;
}
@using System.Web.UI.WebControls

@Html.DevExpress().GridView(
    settings =>
    {
        settings.Name = "gvPayroll";
        settings.CallbackRouteValues = new { Controller = "Payroll", Action = "PayrollGridPartial" };
        settings.Width = Unit.Percentage(100);
        settings.KeyFieldName = "Id";
        settings.Columns.Add("FIRSTNAME", PAYROLLResource.FIRSTNAME);
        settings.Columns.Add("LASTNAME", PAYROLLResource.LASTNAME);
        settings.Columns.Add("RIGHTGROUPNAME", PAYROLLResource.RIGHTGROUPNAME);
        settings.Columns.Add("DISABILITYTYPENAME", PAYROLLResource.RIGHTSTYPENAME);
        settings.Columns.Add("AMOUNT", PAYROLLResource.AMOUNT);
        settings.ClientSideEvents.BeginCallback = "gvPayroll_OnBeginCallback";

        settings.SettingsBehavior.AllowFocusedRow = true;
    }).BindToLINQ(string.Empty, string.Empty, (s, e) =>
    {
        e.QueryableSource = Model.PayrollList;
    }).GetHtml()

模型代码,以防万一:

public class PayrollModel
{
        public PayrollModel()
        {
            PayrollSearch = new PAYROLLVIEWSearch();
        }

        public PAYROLLVIEWSearch PayrollSearch { get; set; }
        public IQueryable<PAYROLLVIEW> PayrollList { get; set; }
}

我希望你们能够提供帮助,因为我的DevExpress支持已过期,而且我真的不知道我做错了什么。

由于

0 个答案:

没有答案