我有我的觀點一個按鈕時,火就執行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")
)
)