I am looking at an example of how to use MVC Contrib Grid :

http://www.4guysfromrolla.com/articles/031611-1.aspx

I am already using a @model on the page for something else, and I want to be able to create up to 6 grids on my page. Is it possible to pass a method that returns the grid contents to the Grid object?

有帮助吗?

解决方案

You can pass any number of collections from the controller action to the view through ViewData or ViewBag.

public ActionResult Index()
{
   ViewData["foos"] = GetFoos();
   ViewData["bars"] = GetBars();
   ViewData["bazz"] = GetBazz();

   return View(/*model*/);
}

And in the view

@Html.Grid((IEnumerable<Foo>)ViewData["foos"]).Columns(...)
@Html.Grid((IEnumerable<Bar>)ViewData["bars"]).Columns(...)
@Html.Grid((IEnumerable<Bazz>)ViewData["bazz"]).Columns(...)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top