Generic alternative for @model in Razor view

  1. #1

    Generic alternative for @model in Razor view

    Hi,

    I'm studying the GridPanelFor example. It uses the @model keyword to define model type on which the grid should be built.
    @model IEnumerable<Ext.Net.MVC.Examples.Areas.Models.GridEmployee>
    I would like to pass that type from the controller, to be able to use a single view for multiple models.

    My controller is:

    public ActionResult RenderWindow() {
    
                Ext.Net.Examples.DataService ds = new Ext.Net.Examples.DataService();
                return new Ext.Net.MVC.PartialViewResult { ViewName = "Window"};
                
            }
    Any ideas on how to do it?
    Thank you.
    Last edited by millenovanta; Dec 09, 2012 at 6:44 PM.
  2. #2
    UPDATE:

    I found a way setting in my view
    1
    @model IEnumerable<object>
    Now I don't know how to passa that "object" through controller.
    How can I modify my controller to pass the specific (Ext.Net.MVC.Examples.Areas.Models.GridEmployee or some others) model to the view?

    Thanks
  3. #3
    I would be interested to see what you were able to come up with here.
  4. #4
    Quote Originally Posted by JakeM View Post
    I would be interested to see what you were able to come up with here.
    I have done it like that:
    public ActionResult RenderWindow() {
                 List<Employee> = db.where... //build your data set
                 Ext.Net.Examples.DataService ds = new Ext.Net.Examples.DataService();            return new Ext.Net.MVC.PartialViewResult { ViewName = "Window", Model = mylist}; //add model =                     }

Similar Threads

  1. [CLOSED] [Razor] Using Model in MVC View
    By UnifyEducation in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: May 02, 2012, 4:38 PM
  2. Using model var in mvc view
    By sinai.doron in forum 1.x Help
    Replies: 1
    Last Post: Nov 09, 2011, 5:19 PM
  3. [CLOSED] Grid.view.refreshRow too slow. Is there an alternative?
    By jchau in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 16, 2011, 10:40 PM
  4. [CLOSED] EXT.NET and ASP.NET MVC View Model
    By SymSure in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 18, 2011, 6:04 PM
  5. [CLOSED] Null view model with PartialViewRenderer
    By paulc in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Feb 17, 2011, 7:30 AM

Tags for this Thread

Posting Permissions