Domanda

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?

È stato utile?

Soluzione

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(...)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top