网格到列表视图 ASP.NET MVC Kendo

Grid to list view ASP.NET MVC Kendo

我是 ASP.NET MVC 和 Kendo 的新手,需要您的帮助。

我需要在同一页面中以网格和列表模式显示数据。请建议什么是最好的 way/approach 来实现这一点。我应该同时使用列表和网格视图,并让它们在用户更改时隐藏和显示,或者这可以通过 CSS 单独完成,请建议。

无法在css中完成,因为Gridview和Listview是两个不同的js组件。我建议您使用共享数据源并创建两个不同的组件 Demo

$("#grid").kendoGrid({
                        dataSource: productsDataSource,
                        autoBind: false,
                        pageable: true,
                        height: 300,
                        selectable: true,
                        columns: [
                            {field: "ProductName", title: "ProductName"},
                            { field: "UnitPrice", title: "Unit Price", format: "{0:c}", width: "100px" },
                            { field: "UnitsInStock", title:"Units In Stock", width: "100px" },
                            { field: "Discontinued", width: "100px" }
                        ]
                    });

$("#listView").kendoListView({
                dataSource: productsDataSource,
                template: kendo.template($("#template").html())
            });