PDA

View Full Version : [CLOSED] StoreParameter on ObjectDataSource



ptrourke
Oct 16, 2013, 4:46 PM
Another one of those kindergarten questions:

Can I use a StoreParameter with an ObjectDataSource? For example, suppose I have a method like this:




public class Town
{
public string TownName {get; set;}
public string StateCode {get; set;}
public string ZipCode {get; set;}
public int Population {get; set;}

public static List<Town> ListTownsInState(string StateCode)
{
// [code that returns a list of towns from the database for a state]
}
}

<asp:ObjectDataSource ID="StateTownsDataSource" runat="server" SelectMethod="ListTownsInState" TypeName="Town">
<SelectParameters>
<asp:Parameter Name="StateCode" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
<ext:Store ID="StateTownsStore" runat="server" DataSourceID="StateTownsDataSource" ClidnetIDMode="static">
<Parameters>
<ext:StoreParameter Name="StateCode" Value="MO" Mode="Value" />
</Parameters>
<Model>
<ext:Model ID="StateTownModel" runat="server" IDProperty="TownName">
<Fields>
<ext:ModelField Name="TownName" Type="String" />
<ext:ModelField Name="StateCode" Type="String" />
<ext:ModelField Name="ZipCode" Type="String" />
<ext:ModelField Name="Population" Type="Int" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
<ext:GridPanel ID="StateTownPanel" Title="Towns in State" Border="true" StoreID="StateTownsStore" runat="server" ClientIDMode="static">
<ColumnModel>
<Columns>
<ext:Column ID="Column_TownName" DataIndex="TownName" runat="server" Text="Town" Type="String" />
<ext:Column ID="Column_StateCode" DataIndex="StateCode" runat="server" Text="State" Type="String" />
<ext:Column ID="Column_ZipCode" DataIndex="ZipCode" runat="server" Text="Zip Code" Type="String" />
<ext:Column ID="Column_Population" DataIndex="Population" runat="server" Text="Population" Type="Int" />
</Columns>
</ColumnModel>
<TopBar>
<ext:Toolbar ID="TownsToolbar" runat="server">
<Items>
<ext:Button ID="LoadTownsButton" runat="server" Text="Load Towns for Missouri">
<Listeners>
<Click Handler="#{StateTownsStore}.reload();>
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
</ext:GridPanel>


Should this work? Or am I missing something? When I run my equivalent code, I am not getting the value "MO" for the parameter StateCode in ListTownsInState in the debugger.

Vladimir
Oct 16, 2013, 4:49 PM
Please see the following sample
http://examples2.ext.net/#/GridPanel/Paging_and_Sorting/Page/

ptrourke
Oct 16, 2013, 4:55 PM
Ok, thanks, that's what I was afraid of ;-).


Please see the following sample
http://examples2.ext.net/#/GridPanel/Paging_and_Sorting/Page/