- Home
- Forum
- ASP.NET MVC
- Populate Grid from Partial View
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
}
$(function () {
GetOpenJobcards();
$('#Devices').change(function () {
GetOpenJobcards();
});
});
function GetOpenJobcards() {
$.ajax({
type: "GET",
url: '@Url.Action("GetOpenJobcardsByModel", "Jobcard")',
data: { deviceModel: $('#Devices').val() },
success: function (data) {
$('#GridContainer').html(data);
//ej.widget.init($('#TheGrid'));
},
})
}
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
SIGN IN To post a reply.
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.
- Partial View and main view pages
- 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.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
NE Neill
- Oct 18, 2017 03:11 PM UTC
- Oct 20, 2017 04:41 AM UTC