PDA

View Full Version : [CLOSED] Add record into store of combo box doesnt work first time



glenh
Aug 25, 2015, 7:46 AM
Hi

I have a situation where I want to add a record into a store of a combo box. However, this never works the first time i.e. If I click the add button once it doesnt get added into the store but if I hit the add button a second time - it is then added.

Alternatively, if I open the dropdown (by clicking the drop down arrow) and then hit the add button for the first time it works.

After some advice here, thanks!



<ext:ResourceManager runat="server" ></ext:ResourceManager>
<ext:Button Text="Holder" runat="server">
<Menu>
<ext:Menu runat="server">
<Items>
<ext:ComboBox runat="server" ID="dd" DisplayField="WishlistName" ValueField="WishlistName">
<Store>
<ext:Store runat="server" ID="storeWishlists">
<Model>
<ext:Model runat="server" Name="Wishlist" IDProperty="WishlistName">
<Fields>
<ext:ModelField Name="WishlistName" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
</ext:ComboBox>
<ext:Button ID="Button1" Text="Add" runat="server">
<Listeners>
<Click Fn="Wishlist1.addRecord" Scope="Wishlist1"></Click>
</Listeners>
</ext:Button>
</Items>
</ext:Menu>
</Menu>
</ext:Button>

<script type="text/javascript">
var Wishlist1 = {
addRecord: function() {
this.store.add({ WishlistName: 'Another' });
}
};
Ext.onReady(function() {
Wishlist1.store = <%= storeWishlists.ClientID %>;
});
</script>

Daniil
Aug 25, 2015, 9:03 AM
Hi @glenh,

Please try to set QueryMode="Local" for ComboBox.

glenh
Aug 25, 2015, 8:02 PM
Thanks Daniil

I knew I could count on you!

Daniil
Aug 26, 2015, 6:13 AM
Thank you for that!:) And you are always welcome on the forums!