View Full Version : [CLOSED] FormCollection is empty in a MVC context after using beforeload store listener

Oct 31, 2012, 2:29 PM
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();";
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">
<ext:Store ID="Store1" runat="server">
<ext:Model ID="Model1" runat="server">
<ext:ModelField Name="Id" Type="Int" />
<ext:AjaxProxy Url="/Research/GetData">
<ext:JsonReader TotalProperty="total" Root="data">
<BeforeLoad Handler="onBeforeLoad(store, operation, App._fp);" />
<ext:Column ID="Column1" runat="server" Text="ID" Width="40" DataIndex="Id" />

Main Page [Aspx]

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html>
<head runat="server">
<script type="text/javascript">
var onClick = function () {
url: "/Research/StorePartial",
'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];
<ext:ResourceManager runat="server">
<ext:Viewport ID="Viewport1" runat="server" Layout="BorderLayout" AutoScroll="true">
<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">
<ext:Parameter Name="containerID" Value="App._pnlCptySearchView" Mode="Value" />
<ext:Panel ID="_pnlLoader" runat="server" Border="false" Header="false" Region="Center"
<Loader ID="Loader2" runat="server" AutoLoad="false" Mode="Component" RemoveAll="true" />

Oct 31, 2012, 5:32 PM
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);

Oct 31, 2012, 5:44 PM
Thank you it works