Jun 25, 2010, 1:38 PM
[CLOSED] [1.0] Accessing instance of store defined in custom server control
We have a grid that we are trying to convert to a server control so that we can use it across multiple pages, to encapsulate everything we are defining the store in that class as well.
We are having an issue with this though because there is another control on our page that uses that store (by way of property). When we try and load the page, it throws an exception that the store isnt defined. Is there anything we need to be doing special to control the rendering order so that the store is defined before?
I'll try and post a small snippet of what we're doing below.. i've removed alot of the irrelevant code from the example
Markup
We are having an issue with this though because there is another control on our page that uses that store (by way of property). When we try and load the page, it throws an exception that the store isnt defined. Is there anything we need to be doing special to control the rendering order so that the store is defined before?
I'll try and post a small snippet of what we're doing below.. i've removed alot of the irrelevant code from the example
Markup
<ext:SearchField
ID="txtSearch"
runat="server"
EmptyText="Search Employee/Report ID"
StoreID="stoStuffToSearch"
Width="185"
ParamName="employeeNameReportId" />
<ext:ManagerApprovalGrid runat="server" />
C#
public class ManagerApprovalGrid : GridPanel
{
public ManagerApprovalGrid()
{
this.ID = "grdApproval";
this.Height = 370;
this.AutoExpandColumn = "ProjectName";
this.AutoExpandMin = 100;
this.AutoExpandMax = 5000;
this.ColumnLines = true;
this.MemoryIDField = "ExpenseItemOID";
this.SelectionMemory = SelectionMemoryMode.Enabled;
this.TopBar.Add(BuildTopBar());
this.SelectionModel.Add(BuildSelectionModel());
BuildColumnModel();
this.View.Add(BuildView());
this.LoadMask.Msg = "Loading Expense Items";
this.LoadMask.ShowMask = true;
this.SaveMask.Msg = "Saving Selections...";
this.SaveMask.ShowMask = true;
this.Listeners.BeforeRender.Handler = "this.colModel.setRenderer(0, renderSelectColumn);";
this.Listeners.AfterRender.Fn = "setGridColumnEvents";
this.Listeners.Command.Fn = "handleGridCommand";
this.Listeners.CellClick.Fn = "grdApproval_CellClick";
this.Plugins.Add(BuildCellToolTopPlugin());
this.Init += new System.EventHandler(ManagerApprovalGrid_Init);
}
private Store BuildStore()
{
Store store = new Store();
store.ID = "stoStuff";
store.GroupField = "ReportID";
store.RemoteSort = true;
store.RemoteGroup = true;
store.PruneModifiedRecords = false;
store.WarningOnDirty = false;
store.RefreshAfterSaving = RefreshAfterSavingMode.Always;
store.SerializationMode = SerializationMode.Complex;
store.UpdateProxy.Add(
new HttpWriteProxy
{
Url="../UpdateProxy",
Method = HttpMethod.POST
}
);
store.Proxy.Add(
new Ext.Net.HttpProxy
{
Url = "../Proxy"
}
);
store.BaseParams.Add(new Parameter
{
Name = "start",
Mode = ParameterMode.Raw,
Value = "0"
});
store.BaseParams.Add(new Parameter
{
Name = "limit",
Mode = ParameterMode.Raw,
Value = "#{pagingToolbar}.pageSize"
});
store.BaseParams.Add(new Parameter
{
Name = "sort",
Mode = ParameterMode.Raw,
Value = "#{ddlSortBy}.getValue()"
});
store.BaseParams.Add(new Parameter
{
Name = "dir",
Mode = ParameterMode.Raw,
Value = "#{btnSortDir}.pressed ? 'DESC' : 'ASC'"
});
store.Reader.Add(
new Ext.Net.JsonReader
{
IDProperty = "ID",
Root = "Items",
TotalProperty = "Total",
Fields =
{
//Records...
}
}
);
RecordField incurredDate = new RecordField("Incurred");
incurredDate.Convert.Fn = "Ext.util.decodeMSDate";
store.Listeners.CommitDone.Fn = "stoStuff_CommitDone";
return store;
}
}
Last edited by geoffrey.mcgill; Jul 07, 2010 at 2:23 AM.