我在局部视图中使用了kendo网格,我通过读取动作获取数据源,fiddler显示数据即将到来但在网格上无法看到。代码:
@model AAS.Management.Models.AdvertisementModel
@using (@Html.BeginForm()) {
@*some other divs*@
<div class="InfoRow">
<div class="display-label">
@AAS.Management.Resources.Names.DeleteDate
</div>
<div class="display-field">
@(Html.Kendo().DatePicker()
.Name("DeleteDate")
.Format("dd.MM.yyyy")
.Value(Model.DeleteDate)
.HtmlAttributes(new { style = "width:150px" })
)
</div>
<div>
<button name="btnUpdate" type="submit"> Update</button>
</div>
<div>
@(Html.Kendo().Grid<AAS.Management.Models.AdvertisementContentModel>()
.Name("gridAdvertisementContent")
.AutoBind(true)
.Columns(c =>
{
c.Bound(p => p.ID).Hidden();
c.Bound(p => p.ContentURL).Title(AAS.Management.Resources.Names.AdvertisementContent_ContentURL);
c.Bound(p => p.DeviceID).Title(AAS.Management.Resources.Names.Device);
c.Bound(p => p.PlatformID).Title(AAS.Management.Resources.Names.Platform);
c.Bound(p => p.State).Title(AAS.Management.Resources.Names.AdvertisementContent_State);
})
.DataSource(d => d
.Ajax()
.Model(m => m.Id(p => p.ID))
.Read(r => r.Action("AdvertisementContentRead", "Customer", new { AdvertisementID = Model.ID }).Type(HttpVerbs.Get))
)
)
</div>
</div>
}
public JsonResult AdvertisementContentRead( long AdvertisementID)
{
return Json(AdvertisementContentService.GetAll(AdvertisementID).result,JsonRequestBehavior.AllowGet);
}
我在点击按钮的弹出窗口中加载了这个局部视图。这里有什么问题?我是mvc和kendo的新手,可能存在逻辑错误,当弹出窗口填充时,我可以使用其他方法填充此部分视图吗?
答案 0 :(得分:0)
我通过将两个模型放在一起解决了这个问题:
@model Tuple< AAS.Management.Models.AdvertisementModel,IEnumerable< AAS.Management.Models.AdvertisementContentModel>>
@using (@Html.BeginForm()) {
@*divs for first model*@
@(Html.Kendo().Grid(Model.Item2)
.Name("gridAdvertisementContent")
.Columns(c =>
{
c.Bound(p => p.ID).Hidden();
c.Bound(p => p.ContentURL).Title(AAS.Management.Resources.Names.AdvertisementContent_ContentURL);
c.Bound(p => p.DeviceID).Title(AAS.Management.Resources.Names.Device);
c.Bound(p => p.PlatformID).Title(AAS.Management.Resources.Names.Platform);
c.Bound(p => p.State).Title(AAS.Management.Resources.Names.AdvertisementContent_State);
})
)}