View Full Version : Manually adding items to store

26 Mar 2012, 12:54 AM

I need to build a combobox that saves the recently entered values to a cookie. Now what I tried to do is bind the combobox to a store without a proxy and insert the current combo box value into the store using the add() function when the user clicks on a button:

onConnectClick: function(button) {
var form = button.up('form'),
host = form.down('#host'),
user = form.down('#user'),
pass = form.down('#pass');

var store = this.getRecentHostnamesStore();
var i = store.findExact('host', host.getValue());
if(i == -1) {
store.add({'host': host.getValue()});

var data = [];
store.each(function(item) {

var x = Ext.encode(data);
alert(x); // Should be put into cookie here

What I observe is that the alert gives only the last value entered, not the ones already inside the store. After some investigation I found out that the store has a filter that filters the store for the last entered value which I suppose has something to do with the combobox. Can someone explain why this filter is set? Maybe I'm doing something wrong.

Second question: Is there an easier way of serializing a store to a cookie, maybe a dedicated CookieStorage proxy?


26 Mar 2012, 7:51 AM
Do you have typeAhead? When a string is typed in, this should be the only reason why the store is filtered from the combobox.

27 Mar 2012, 12:21 AM
I haven't specified a value for typeAhead, so it should default to false. Now I set it explicitly to false but the store is still being filtered when adding a new item...

27 Mar 2012, 12:25 AM
Here's my combobox definition:

xtype: 'combobox',
itemId: 'host',
fieldLabel: 'Hostname',
anchor: '100%',
store: 'RecentHostnames',
displayField: 'host',
queryMode: 'local'

27 Mar 2012, 12:42 AM
I just put a breakpoint in the filter() function of the store and it is always called when typing a char in the combobox. Is there any option other than typeAhead that could be causing this?