0
votes

I use kendo grid inside a partial view, I take the datasource through read action, fiddler shows that the data is coming but cannot be seen on the grid. Code:

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

I load this partial view inside a popup on a button click. What is the problem here? I am new in mvc and kendo, probably there is a logical mistake, can I use another approach to fill this partial view when the popup is populated?

1

1 Answers

0
votes

I solved this by passing two models together:

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