ASP .Net MVC Наполнение динамической таблицы содержимым из контроллера
Мне нужно создать динамическую таблицу и записывать в нее значения вычисленные в контроллере. В ASP MVC я всего 2 дня, но уже кучу статей перелопатил, везде какие-то отрывочные куски кода толком без объяснений. Уже пытался сделать подобное на Jquery, Вот View
<html>
<head>
<title>jqGrid</title>
<script src="~/Scripts/jquery-1.10.2.min.js" type="text/javascript"></script>
<link href="~/Content/themes/base/jquery.ui.all.css" rel="stylesheet" type="text/css" />
<link href="~/Content/jquery.jqGrid/ui.jqgrid.css" rel="stylesheet" type="text/css" />
<script src="~/Scripts/jquery-ui-1.8.11.min.js" type="text/javascript"></script>
<script src="~/Scripts/jquery.jqGrid.min.js" type="text/javascript"></script>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
</head>
<body>
<h2>jQGrid</h2>
<table id="jqg"></table>
<script type="text/javascript">
$(document).ready(function () {
$("#jqg").jqGrid({
url: '@Url.Action("GetData")',
datatype: "json",
colNames: ['Номер платежа', 'Дата платежа', 'Размер платежа по телу', 'размер платежа по %', 'Остаток основного долга'],
colModel: [
{ name: 'Id', index: 'Id', width: 30, stype: 'text' },
{ name: 'Name', index: 'Date', width: 150, sortable: true},
{ name: 'Author', index: 'Amount$', width: 150, sortable: true },
{ name: 'Year', index: 'Amount%', width: 100, sortable:false },
{ name: 'Price', index: 'Remain', width: 80, align: "right", sortable: true }
],
rowNum: 5, // число отображаемых строк DODELAT
// загрузка только один раз
sortname: 'Id', // сортировка по умолчанию по столбцу Id
sortorder: "desc", // порядок сортировки
caption: "График платежей"
});
});
</script>
</body>
</html>
А это контроллер:
public ActionResult Index()
{
return View(new Calculate());
}
[HttpPost]
public ActionResult Index(Calculate c, int FN, int SN, int TN, string calculate)
{
if (calculate == "add")
{
double i = (double)TN / 12;
n = SN;
double k = (i * Math.Pow(1 + i, n)) / (Math.Pow(1 + i, n) - 1);
summ = (double)FN * k;
total = summ;
c.result = total;
return View(c);
}
return RedirectToAction("Resultat");
}
[HttpGet]
public ActionResult Resultat()
{
return View(new Result());
}
static List<Result> results = new List<Result>();
static CalculatorController()
{
for (int i = 0; i < 12; i++)
{
int j = 1;
results.Add(new Result { Id = j, date = 2, payment = 100, percent_payment = 100, remain_debt = 220 });
j++;
}
}
public string GetData()
{
return JsonConvert.SerializeObject(results);
}
В результате выводиться только это
