May 08, 2014, 7:08 PM
AjaxProxy ExtraParams doesn't work
I have a combobox which fills it's data through an ASMX Web Service and I would like to pass an Extra Param (the country) in order to show only that country's cities. Country name must come from another Ext.NET control, a Cycle button's text. But the page cannot even load because it says it can't find the cycle button control. Following are the CycleButton's, the ComboBox's and the Web service's code.
This works:
Kind regards,
C.S
<ext:CycleButton MinWidth="197" Width="197" ID="MyCycleButton" runat="server" ShowText="true">
<Menu>
<ext:Menu runat="server" MaxHeight="200">
<Items>
</Items>
</ext:Menu>
</Menu>
<Listeners>
<Click Handler="MyApp.sampleFunction(this,e)" />
</Listeners>
</ext:CycleButton>
<ext:ComboBox
ID="ComboBoxCitySelection"
runat="server"
AllowBlank="false"
DisplayField="CityName"
ValueField="CityName"
TypeAhead="false"
Hidden="true"
LabelCls="x-form-item-label"
AutoFocus="true"
PageSize="5"
HideBaseTrigger="true"
MinChars="0"
LabelStyle="margin-left: 85px;"
TriggerAction="Query">
<ListConfig LoadingText="Searching...">
<ItemTpl runat="server">
<Html>
<div style="font-weight: normal;">
<span>{CityName}</span>
</div>
</Html>
</ItemTpl>
</ListConfig>
<Store>
<ext:Store ID="StoreSearchCities" runat="server" AutoLoad="false" PageSize="5" RemoteFilter="true">
<Proxy>
<ext:AjaxProxy Url="../../Services/UserService.asmx/GetCountryCities" " FilterParam="CityName">
<ActionMethods Read="POST" />
<Reader>
<ext:JsonReader Root="data" />
</Reader>
<ExtraParams>
<ext:Parameter Name="Country" Value="#{MyCycleButton}.getText()" Mode="Raw" />
</ExtraParams>
</ext:AjaxProxy>
</Proxy>
<Model>
<ext:Model runat="server" IDProperty="CityName" AutoDataBind="true">
<Fields>
<ext:ModelField Name="CityName" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
</ext:ComboBox>
[WebMethod(EnableSession = true)]
public void GetCountryCities(string country)
{
HttpContext.Current.Response.ContentType = "application/json";
var requestParams = new StoreRequestParameters(HttpContext.Current);
int start = requestParams.Start;
int limit = requestParams.Limit;
string filter = !string.IsNullOrEmpty(requestParams.Query) ? requestParams.Query : "";
if (filter == "*")
filter = "";
Paging<City> resultCities = UserDataAccess.GetCountryCities(start, limit, filter, country);
HttpContext.Current.Response.Write(JSON.Serialize(resultCities));
}
When I use the following Extra Params the ASMX country paramater is filled correctly, but I just want to be dynamic..This works:
<ExtraParams>
<ext:Parameter Name="Country" Value="Greece" Mode="Value" />
</ExtraParams>
So the question is, how i can pass every time the CycleButton's text as an extra parameter to my ASMX service?Kind regards,
C.S