我有以下ViewModel
public class IndexViewModel
{
public string[,] Table1 { get; set; }
}
在控制器中我填充了这个属性
public ActionResult Index()
{
var model = new IndexViewModel();
model.Table1 = new string[6, 7] {
{ "", "Kia", "Nissan", "Toyota", "Honda", "Mazda", "Ford" },
{ "2012", "10", "11", "12", "13", "15", "16" },
{ "2013", "10", "11", "12", "13", "15", "16" },
{ "2014", "10", "11", "12", "13", "15", "16" },
{ "2015", "10", "11", "12", "13", "15", "16" },
{ "2016", "10", "11", "12", "13", "15", "16" }
};
return View(new IndexViewModel());
}
如何在javascript中将此Model.Table1
属性设置为属性?
<script>
var hot = new Handsontable(container, {
data: @Html.Raw(Model.Table1), // this does not work
});
</script>