我有我的观点一个按钮时,火就执行GetReport(),它执行:由JSON公众的ActionResult GetReport(INT licenseId)。如何将模型从json传递到视图?
现在公众的ActionResult GetReport(INT licenseId)填写我的模型,并通过JSON返回。
万物是正确的,但我不知道如何链接返回模式(通过JSON)我的看法?
function GetReport() {
var id = $("select#LicensesDropdown").val();
if (id == null || id == '')
return;
var inputParams = "{licenseId : '" + id + "'}";
var abc;
$.ajax({
url: "/Members/ClientMonitoring/GetReport",
type: 'POST',
dataType: 'json',
data: inputParams,
contentType: 'application/json; charset=utf-8',
success: function (msg) {
var d = Date.parseJSON(msg.StartDate);<-----------------returned filled model-------------
here i don't know how to fill my grid now
}
});
}
我的模型------------------------------------ -------------------------------------------------- -------------------------------
public class ReportBaseModel
{
public List<person> MonitoringLicenseModelsList { get; set; }
}
我的行动结果--------- -------------------------------------------------- -----------------------------------------------
[HttpPost]
public ActionResult GetReport(int licenseId)
{
// fill reportmodel it contains list of data and return it by jason
return Json(reportmodel);
}
在我看来---------------------------------------------- -------------------------------------------------- --------------
@model Karanoos.Areas.Members.Models.CompositModels.ReportBaseModel
<input id="ButtonGetReport" type="button" value="Report" class="btnnormal" onclick="GetReport();" />
@{
var grid = new WebGrid(source: Model.LicensesClientsPacketModelsList,
defaultSort: "LicenseUI",
rowsPerPage: 3);
}
<div id="grid">
@grid.GetHtml(
tableStyle: "grid",
headerStyle: "head",
alternatingRowStyle: "alt",
columns: grid.Columns(
grid.Column("LicenseUI"),
grid.Column("AccountName"),
grid.Column("AppName")
)
)