Mar 18, 2011, 5:27 PM
Exception in Ajax combobox
Hi Team,
I am trying to use linked comboboxes.
Please have a look to the below code.
This is working fine when I am having subcategories(2nd dropdown) for the categories(1st dropdown).
But when there is no subcategory,
<Load Handler="#{SubCategory}.setValue(#{SubCategory}.st ore.getAt(0).get('SubCategoryId'));" />
I am getting exception,store.getAt(...) is null or not an object.
How can I check if no subcategories are loaded?or is there any other way?
I am trying to use linked comboboxes.
Please have a look to the below code.
<ext:Store runat="server" ID="stddlSubCategory" AutoLoad="false" OnRefreshData="SubCatRefresh">
<DirectEventConfig>
<EventMask ShowMask="false" />
</DirectEventConfig>
<Reader>
<ext:JsonReader IDProperty="SubCategoryId">
<Fields>
<ext:RecordField Name="SubCategoryId" Mapping="SubCategoryId" />
<ext:RecordField Name="SubCategoryName" Mapping="SubCategoryName" />
</Fields>
</ext:JsonReader>
</Reader>
<Listeners>
<Load Handler="#{SubCategory}.setValue(#{SubCategory}.store.getAt(0).get('SubCategoryId'));" />
</Listeners>
</ext:Store>
<ext:Store ID="storeddlCategory" runat="server" AutoDataBind="true">
<Reader>
<ext:JsonReader IDProperty="CategoryId">
<Fields>
<ext:RecordField Name="CategoryId" />
<ext:RecordField Name="CategoryName" />
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
<ext:SelectBox ID="ddlCategory" TriggerAction="All" runat="server" StoreID="storeddlCategory"
FieldLabel="Category" DisplayField="CategoryName" ValueField="CategoryId" DataIndex="CategoryId"
EmptyText="Select a category...">
<Listeners>
<Select Handler="#{SubCategory}.clearValue(); #{stddlSubCategory}.reload();" />
</Listeners>
</ext:SelectBox>
<ext:ComboBox ID="SubCategory" runat="server" FieldLabel="Sub-Category" StoreID="stddlSubCategory"
TypeAhead="true" Mode="Local" ForceSelection="true" TriggerAction="All" DisplayField="SubCategoryName"
ValueField="SubCategoryId" EmptyText="No Subcategory..." ValueNotFoundText="Loading...">
</ext:ComboBox>
This is working fine when I am having subcategories(2nd dropdown) for the categories(1st dropdown).
But when there is no subcategory,
<Load Handler="#{SubCategory}.setValue(#{SubCategory}.st ore.getAt(0).get('SubCategoryId'));" />
I am getting exception,store.getAt(...) is null or not an object.
How can I check if no subcategories are loaded?or is there any other way?