[CLOSED] Load window content from a controller method

Page 2 of 3 FirstFirst 123 LastLast
  1. #11
    Please clarify where is the Window defined? Inside the parent page or the child one?
  2. #12
    Well the double click on a grid row calls the action method that returns a partial view
    return this.PartialExtView(
       viewName: "Edit",
       model: viewModel
    );
    return this.Direct();
    and the view is

    <html>
    <head>
         <meta name="viewport" content="width=device-width" />
         <title></title>
     </head>
     <body>
          <div>
                @( X.Window().ID("Edit")
                                      .Title(Model.NAME)
                                       .Icon(Icon.ApplicationViewDetail)
                                       .Width(800)
                                      .Height(550)
                                      .Layout(LayoutType.Fit)
                                      .Border(true)
    Can I make this render parent, render in parent or whatever the syntax is...?
  3. #13
    calls the action method that returns a partial view
    You should call the action from the parent page.
  4. #14
    Do you have an example how to hack/trick this?

    Thnx
  5. #15
    Ok, how do you call the controller action currently?
  6. #16
    From the grid panel:

    .DirectEvents(de =>
                        {
                            de.ItemDblClick.Url = "List/DblClick";
                            de.ItemDblClick.CleanRequest = true;
                            de.ItemDblClick.EventMask.ShowMask = true;
                            de.ItemDblClick.Method = HttpMethod.GET;
                            de.ItemDblClick.ExtraParams.Add(new Parameter("id", "record.get('REF')", ParameterMode.Raw));
                        })
  7. #17
    Ok, there might a few approaches.

    For example, this one.

    Index.cshtml
    @{
        var X = Html.X(); 
    }
    
    <!DOCTYPE html>
    <html>
    <head>
        <title>Ext.Net.MVC v2 Example</title>
    
        <script>
            var openWindow = function(recordId) {
                App.Window1.removeAll();
                App.Window1.show();
                App.Window1.load({
                    params: {
                        recordId: recordId
                    }
                });
            };
        </script>
    </head>
    <body>
        @X.ResourceManager()
    
        @(X.Window()
            .ID("Window1")
            .Title("Window")
            .Hidden(true)
            .Height(100)
            .Loader(X.ComponentLoader()
                .AutoLoad(false)
                .Mode(LoadMode.Html)
                .Scripts(true)
                .Url(Url.Action("WindowContent"))
                .Params(new
                {
                    containerId = "Window1"
                })
            )
        )
    
        @(X.Panel()
            .Loader(X.ComponentLoader()
                .Mode(LoadMode.Frame)
                .Url(Url.Action("Child"))
            )
        )
    </body>
    </html>
    Child.cshtml
    @{
        var X = Html.X(); 
    }
    
    <!DOCTYPE html>
    <html>
    <head>
        <title>Ext.Net.MVC v2 Example</title>  
    </head>
    <body>
        @X.ResourceManager()
        
        @(X.GridPanel()
            .Store(X.Store()
                .Model(X.Model()
                    .Fields("id", "text")
                )
                .DataSource(new object[]
                {
                    new 
                    {
                        id = 1,
                        text = "Some Text 1"   
                    },
                    new 
                    {
                        id = 2,
                        text = "Some Text 2"   
                    }
                })
            )
            .ColumnModel(
                X.Column().Text("id").DataIndex("id"),
                X.Column().Text("text").DataIndex("text")
            )
            .Listeners(events => 
                events.ItemDblClick.Handler = "parent.openWindow(record.getId());"
            )
        )
    </body>
    </html>
    WindowContent.cshtml
    @model string
    
    @(Html.X().Label()
        .Text("The Window has been opened for the record with id - " + Model)
    )
    Controller
    public ActionResult Index()
    {
        return View();
    }
    
    public ActionResult Child()
    {
        return View();
    }
    
    public ActionResult WindowContent(string containerId, string recordId)
    {
        return new PartialViewResult
        {
            ContainerId = containerId,
            RenderMode = RenderMode.AddTo,
            Model = recordId
        };
    }
  8. #18
    With a little bit of tweaking around, this solution did work. Thank you!
  9. #19
    Would it be possible to pass in parameters for the Url to this function:
    var openWindow = function(recordId)
    as to have a generic window for opening all the record edit windows for any grid in the application?

    Basically, to move

    .Url(Url.Action("WindowContent"))
    to the openWinow javascript function with controller action path passed in as parameters?

    In my case I have Url.Action("DblClick", "List", new { area = "Sales" })
    Last edited by registrator; Jan 20, 2015 at 11:04 AM.
  10. #20
    It looks I don't quite understand the requirement. You can pass to server any parameters in a similar way as I did with the "recordId" parameter in my example, but, probably, it is not what you are looking for. It looks you want to change something in the design, but I am not sure what exactly. Please elaborate on that.
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. Replies: 8
    Last Post: May 12, 2013, 6:19 PM
  2. [CLOSED] [RAZOR] How to access ext.net controls from controller method
    By gets_gui in forum 2.x Legacy Premium Help
    Replies: 5
    Last Post: Sep 13, 2012, 8:12 AM
  3. Load Panel from MVC Controller
    By stu in forum 2.x Help
    Replies: 1
    Last Post: Jun 18, 2012, 11:26 PM
  4. Replies: 1
    Last Post: Apr 09, 2012, 1:07 PM
  5. Load menu panel from controller
    By wadhah in forum 1.x Help
    Replies: 1
    Last Post: Oct 28, 2011, 1:48 PM

Tags for this Thread

Posting Permissions