使用ASP.NET MVC 3的Wijmo Grid

Yas*_*ser 0 wijmo asp.net-mvc-3

我正在寻找实施Wijmo Grid的示例/教程或指南.

我希望在ASP.NET MVC 3中实现它.我将从我的操作传递动态数据.

请有人帮我解决这个问题.

Dar*_*rov 5

它是一个纯粹的客户端网格,完全与服务器端无关.该文件还似乎很自我解释.我邀请你通过它.

一旦你完成它,事情变得相当标准.

您从一个包含动态数据的视图模型开始:

public class MyViewModel
{
    public object[] Rows { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

然后是一个控制器,将该视图模型提供给视图:

public class HomeController : Controller
{
    public ActionResult Index()
    {
        var model = new MyViewModel
        {
            // This data could of course be dynamic and come from wherever you like it to come
            Rows = new object[] 
            {
                new object[] { 1, "a" },
                new object[] { 2, "b" },
                new object[] { 3, "c" },
            }
        };
        return View(model);
    }
}
Run Code Online (Sandbox Code Playgroud)

最后一个观点:

@model MyViewModel
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Wijmo grid demo </title>
</head>
<body>
    <table id="mytable"></table>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js" type="text/javascript"></script>

    <!--Theme-->
    <link href="http://cdn.wijmo.com/themes/rocket/jquery-wijmo.css" rel="stylesheet" type="text/css" title="rocket-jqueryui" />

    <!--Wijmo Widgets CSS-->
    <link href="http://cdn.wijmo.com/jquery.wijmo-complete.all.2.2.1.min.css" rel="stylesheet" type="text/css" />

    <!--Wijmo Widgets JavaScript-->
    <script src="http://cdn.wijmo.com/jquery.wijmo-open.all.2.2.1.min.js" type="text/javascript"></script>
    <script src="http://cdn.wijmo.com/jquery.wijmo-complete.all.2.2.1.min.js" type="text/javascript"></script>

    <script type="text/javascript">
        $("#mytable").wijgrid({
            data: @Html.Raw(Json.Encode(Model.Rows))
        });
    </script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)