[CLOSED] FormCollection is empty in a MVC context after using beforeload store listener

  1. #1

    [CLOSED] FormCollection is empty in a MVC context after using beforeload store listener

    Hi,
    I want to post search criteria values on FormCollection when loading GridPanel event this is the code below :

    Controller Code:
      public FormPanel CreateFP()
            {
                FormPanel fp = new FormPanel();
                fp.ID = "_fp";
                TextField txtField = new TextField();
                txtField.ID = "_txt";
                txtField.FieldLabel = "Txt";
                Button btn = new Button();
                btn.Text = "click";
                btn.ID = "_btn";
                btn.Listeners.Click.Handler = "onClick();";
                fp.Items.Add(txtField);
                fp.Items.Add(btn);
                return fp;
            }
    
            public ContentResult LoadFP(String containerID)
            {
                ContentResult cr = new ContentResult();
                String script = CreateFP().ToScript(RenderMode.AddTo, containerID);
                //script += GenerateSearchScreensButtonKeyMap().ToScript();
                cr.Content = string.Format("<script>{0}</script>", script);
                return cr;
            }
    
            public ActionResult Research()
            {
                return View();
            }
    
            public StoreResult GetData(FormCollection value)
            {
                String txt = value["_txt"];
                StoreResult sr = new StoreResult();
                return sr;
            }
    
            public ActionResult StorePartial()
            {
                return Content(Ext.Net.ComponentLoader.ToConfig("~/Views/Research/StorePartial.ascx"));
            }
    [ASCX] Partial that contains GridPanel :
    <ext:GridPanel runat="server">
        <Store>
            <ext:Store ID="Store1" runat="server">
                <Model>
                    <ext:Model ID="Model1" runat="server">
                        <Fields>
                            <ext:ModelField Name="Id" Type="Int" />
                        </Fields>
                    </ext:Model>
                </Model>
                <Proxy>
                    <ext:AjaxProxy Url="/Research/GetData">
                        <Reader>
                            <ext:JsonReader TotalProperty="total" Root="data">
                            </ext:JsonReader>
                        </Reader>
                    </ext:AjaxProxy>
                </Proxy>
                <Listeners>
                    <BeforeLoad Handler="onBeforeLoad(store, operation, App._fp);" />
                </Listeners>
            </ext:Store>
        </Store>
        <ColumnModel>
            <Columns>
                <ext:Column ID="Column1" runat="server" Text="ID" Width="40" DataIndex="Id" />
            </Columns>
        </ColumnModel>
    </ext:GridPanel>
    Main Page [Aspx]
    <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <script type="text/javascript">
            var onClick = function () {
                App._pnlLoader.removeAll();
                App._pnlLoader.load(
                        {
                            url: "/Research/StorePartial",
                            params:
                            {
                                'containerID': '_pnlLoader'
                            }
                        });
            };
            var onBeforeLoad = function (store, operation, formPanel) {
                var values = formPanel.getForm().getFieldValues();
                var params = operation;
                for (var v in values) {
                    params[v] = values[v];
                }
            };
        </script>
    </head>
    <ext:ResourceManager runat="server">
    </ext:ResourceManager>
    <body>
        <ext:Viewport ID="Viewport1" runat="server" Layout="BorderLayout" AutoScroll="true">
            <Items>
                <ext:Panel ID="_pnlCptySearchView" runat="server" Border="false" Header="false" Region="North">
                    <Loader ID="Loader1" runat="server" Url="/Research/LoadFP" DisableCaching="true"
                        Mode="Html" Scripts="true">
                        <Params>
                            <ext:Parameter Name="containerID" Value="App._pnlCptySearchView" Mode="Value" />
                        </Params>
                    </Loader>
                </ext:Panel>
                <ext:Panel ID="_pnlLoader" runat="server" Border="false" Header="false" Region="Center"
                    Layout="FitLayout">
                    <Loader ID="Loader2" runat="server" AutoLoad="false" Mode="Component" RemoveAll="true" />
                </ext:Panel>
            </Items>
        </ext:Viewport>
    </body>
    </html>
    Last edited by Daniil; Oct 31, 2012 at 5:50 PM. Reason: [CLOSED]
  2. #2
    Hi @,

    Please apply these changes.

    1. Set up this for the AjaxProxy. FormCollection deals with a POST only.
    <ActionMethods Read="POST" />
    2. You should put any extra parameters into "operation.params".
    var onBeforeLoad = function (store, operation, formPanel) {
        var values = formPanel.getForm().getFieldValues();
    
        operation.params = operation.params || {};
        Ext.apply(operation.params, values);
    };
  3. #3
    Thank you it works

Similar Threads

  1. [CLOSED] Get Empty value for keyDown listener in IE9
    By pattake in forum 1.x Premium Help
    Replies: 3
    Last Post: Mar 25, 2011, 4:36 PM
  2. Replies: 10
    Last Post: Nov 12, 2010, 2:13 PM
  3. Replies: 1
    Last Post: Sep 20, 2010, 8:08 PM
  4. Replies: 0
    Last Post: Jun 26, 2009, 12:32 PM
  5. Store Listener - Only if Store not empty?
    By Tbaseflug in forum 1.x Help
    Replies: 4
    Last Post: Feb 24, 2009, 1:50 PM

Posting Permissions