Populate Grid from Partial View

How do I populate my Grid from a Partial View ajax call?
The Grid does not show up at all.
I'm using version15.3460.0.33
PartialView
@model IEnumerable
@(Html.EJ().Grid("TheGrid")
.Datasource((IEnumerable<object>)ViewBag.jobcards)
.Columns(col =>
{
col.Field("Id").HeaderText("The Id").Width(20).Add();
col.Field("SerialNumber").HeaderText("Serial Number").Width(60).Add();
col.Field("IsSelected").Type("checkbox").HeaderText("Selected").Width(20).Add();
})
)
@Html.EJ().ScriptManager()
View
@using (Html.BeginForm("CloseManufacturingJobs", "Jobcard", FormMethod.Post, new { @class = "form-horizontal", role = Model }))
{
@Html.AntiForgeryToken()

Device Models

@Html.Label("Select Device", new { @class = "control-label" })
@if (@ViewBag.DeviceModels != null)
{
@Html.DropDownList("SelectedDevice", ViewBag.DeviceModels as IEnumerable, new { @class = "form-control", @id = "Devices" })
}
else
{
@Html.DropDownList("SelectedDevice", new SelectList(string.Empty, "Value", "Text"), new { @class = "form-control", @id = "Devices" })
}

Open Job Cards By Model

}
Ajax Method
[HttpGet]
public ActionResult GetOpenJobcardsByModel(string deviceModel)
{
IEnumerable jobcards = dbSatCom.JobCards.OrderByDescending(so => so.WeightFactor)
.Where(jc => jc.SerialNo.StartsWith(deviceModel) && jc.JobcardType == "M" && jc.Status == "O"
&& !jc.SerialNo.Contains("-E-") && !jc.SerialNo.StartsWith("CHE3-CH")).ToList().Select(jcvm => new JobcardViewModel
{
IsSelected = false,
SerialNumber = jcvm.SerialNo
}).OrderBy(x => x.SerialNumber).ToList();
ViewBag.datasource = jobcards;
return PartialView("_OpenJobcards");
}
I'm sure the rendering works because I use the Grid elsewhere, except I am not using a partial view in those instances.
Neill

3 Replies

SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team October 19, 2017 11:07 AM UTC

Hi Neill,  
 
Thanks for contacting Syncfusion Support.  
 
We have already discussed about the Partial View rendering of the Grid in the following Help Document.  
 
 
Please follow the Help Document. If you are still facing any problem, please share the following details to analyze the problem at our end.  
 
  1. Partial View and main view pages
  2. Master page and web.config of your application
 
Regards,  
Seeni Sakthi Kumar S. 



NE Neill October 19, 2017 02:14 PM UTC

Thank you.

I'm not sure what I was doing wrong, but after following the explanation, it is working correctly.


Neill



SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team October 20, 2017 04:41 AM UTC

Hi Neill,  
 
Thanks for the update.  
 
We are happy to hear that your requirement has been resolved. Please get back to us, if you require further assistance on this.  
 
Regards,  
Seeni Sakthi Kumar S. 


Loader.
Up arrow icon