【问题标题】:Kendo MVC Grid inside PartialView cannot bind the incoming dataPartialView 内的 Kendo MVC Grid 无法绑定传入的数据
【发布时间】:2013-12-06 16:43:16
【问题描述】:

我在局部视图中使用剑道网格,我通过读取操作获取数据源,提琴手显示数据即将到来但在网格上看不到。代码:

    @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 的新手,可能有一个逻辑错误,我可以在填充弹出窗口时使用另一种方法来填充这个局部视图吗?

【问题讨论】:

    标签: asp.net-mvc razor kendo-grid


    【解决方案1】:

    我通过将两个模型一起传递来解决这个问题:

    @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);
     })
     )}
    

    【讨论】:

      猜你喜欢
      • 2023-03-16
      • 1970-01-01
      • 2014-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多