将多维数组从viewmodel转换为javascript

时间:2016-12-12 16:52:07

标签: javascript asp.net-mvc

我有以下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>

0 个答案:

没有答案