我一直试图让一个Kendo网格正确填充到IE8内部(使用该程序的人员仍然停留在Windows XP上)。它在IE9,Firefox和Chrome中运行得非常好。
以下是我正在使用的代码。
我的cshtml文件
<!DOCTYPE html>
@model IEnumerable<SymPro.ViewModels.InvestViewModel>
@{
ViewBag.Title = "List Accounts";
}
<p>
@Html.ActionLink("Create New", "Create")
</p>
<font size ="1">
@(Html.Kendo().Grid<SymPro.ViewModels.InvestViewModel>()
.Name("gridInvest")
.Columns(columns =>
{
columns.Bound(p => p.asset_num).Title("Invest. <br/> No.");
columns.Bound(p => p.cusipnum).Title("Security <br/> ID").Width(80);
columns.Bound(p => p.rempar).Title("Remaining <br/> Par").Format("{0:0.00}").Width(100);
columns.Bound(p => p.issuer).Title("Issuer");
columns.Bound(p => p.purdate).Title("Purchased").Width(100);
columns.Bound(p => p.maturdate).Title("Mature/Sell").Width(100);
columns.Bound(p => p.invtype).Title("Type");
columns.Bound(p => p.fund_num).Title("Fund");
columns.Bound(p => p.nomrate).Title("Rate").Format("{0:0.00}");
columns.Bound(p => p.facevalue).Title("Par <br/> Value").Format("{0:0.00}");
columns.Bound(p => p.groupcd).Title("Group");
columns.Bound(p => p.sectorcd).Title("Sector");
columns.Bound(p => p.identity_column).Title("")
.ClientTemplate(@Html.ActionLink("Details", "Details", new { id = "#= identity_column#" }, new { style = "color:blue" })
.ToHtmlString()
);
columns.Bound(p => p.identity_column).Title("")
.ClientTemplate(@Html.ActionLink("Edit", "Edit", new { id = "#= identity_column#" }, new { style = "color:blue" })
.ToHtmlString()
);
columns.Bound(p => p.identity_column).Title("")
.ClientTemplate(@Html.ActionLink("Delete", "Delete", new { id = "#= identity_column#" }, new { style = "color:blue" })
.ToHtmlString()
);
})
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("Invest_Read", "Invest"))
)
.Sortable()
.Scrollable(scr=>scr.Height(450))
)
</font>
我的Invest_Read行动结果
public ActionResult Invest_Read([DataSourceRequest]DataSourceRequest request)
{
decimal initzero = 0000000000000.00M;
string initcode = "";
string DefPublCd = "";
var dbAgencyQuery = (from d in db.dbagency
select d).FirstOrDefault();
if (dbAgencyQuery != null)
{
DefPublCd = dbAgencyQuery.defpublcd;
}
DateTime general = new DateTime(1900, 1, 1);
DateTime? empty = null;
var accounts = (from i in db.invest
join s in db.dbsumcalcs on i.asset_num equals s.asset_num into i_s
from subi_s in i_s.DefaultIfEmpty()
join f in db.fisectasgn on i.ficspkey equals f.cspkey into i_f
from subi_f in i_f.DefaultIfEmpty()
join e in db.sector on subi_f.syseckey equals e.syseckey into f_e
from subf_e in f_e.DefaultIfEmpty()
where subf_e.publcd == DefPublCd
orderby i.maturdate
select new InvestViewModel
{
asset_num = i.asset_num,
cusipnum = i.cusipnum,
rempar = (subi_s == null ? initzero : subi_s.rempar),
issuer = i.issuer,
purdate = (i.maturdate == general || i.maturdate == DateTime.MinValue ? empty : i.purdate),
maturdate = (i.maturdate == general || i.maturdate == DateTime.MinValue ? empty : i.maturdate),
invtype = i.invtype,
fund_num = i.fund_num,
nomrate = i.nomrate,
facevalue = i.facevalue,
creditcode = (subi_s == null ? initcode : subi_s.creditcode),
credrte2 = (subi_s == null ? initcode : subi_s.credrte2),
groupcd = (subf_e == null ? initcode : subf_e.groupcd),
sectorcd = (subf_e == null ? initcode : subf_e.sectorcd),
identity_column = i.identity_column
});
DataSourceResult result = accounts.ToDataSourceResult(request);
return Json(result, JsonRequestBehavior.AllowGet);
}
答案 0 :(得分:1)
确保您已按照documentation中的说明将kendo.aspnetmvc.js文件添加到布局页面。 troubleshooting也可以派上用场。
答案 1 :(得分:0)
请检查使用浏览器开发人员工具生成的html。我认为IE8不支持html5和kendo网格可能使用自定义属性,如data-xxxx。
答案 2 :(得分:0)
我想出了我的问题。在我的View模型InvestViewModel中,我有一个名为@class的变量,它正在程序的其他地方使用,但是当它被传递到网格时,这导致了Kendo的一个问题,即使它是Null。