View Full Version : Mixing proxy data + custom local data into a combobox store : is it possible ?

Bob Wilson
25 Jun 2012, 3:40 AM
Hi all,

I'm trying to figure out how to have a combobox which values are a mix of :
1. Values retrieved on a server via a proxy
2. Custom local values

My following code is :

1. building a store via a proxy, all this via a dedicated function (that encapsulates specific params for the URL to be requested + start & limit params).

2. trying to insert a custom data into this store, with no success at all...

Here is the function that builds my store via a proxy.
This function works as my combobox using the returned store displays the correct values :

function buildStore(viewname, start, limit)
url = HTTP_Root + '/' + viewname + "?ReadViewEntries&outputformat=JSON";

var model = Ext.define('viewRow',
extend: 'Ext.data.Model',
fields: [
{name: 'position', mapping: '@position'},
{name: 'unid', mapping: '@unid'},
{name: 'c1', mapping: 'entrydata[0].text[0]'}

var proxy = Ext.create('Ext.data.proxy.Ajax', {
url: url,
startParam: 'start',
limitParam: 'count',
reader: {
type: 'json',
root: 'viewentry',
totalProperty: '@toplevelentries'

newStore = Ext.create('Ext.data.Store', {
proxy: proxy,
model: model

var operation = Ext.create('Ext.data.Operation', {
action: 'read',
start: start,
limit : limit

return newStore;

Now, when I'm trying to be build manually some new data and insert it into the store, nothing happens.
There are no error messages, but the console displays exactly the same store BEFORE and AFTER the insertion... What am I doing wrong ?

Thanks for your help.

addressBookStore = buildStore('lookupResourcesByName', 1, 1000);
var everybody = {
position: '000',
unid: '007',
c1: 'James Bond'

addressBookStore.insert(0, everybody);

25 Jun 2012, 3:57 AM
The object in the console reflects it's current state:

var o = {
foo: 1
delete o.foo;
o.bar = 2;

Chances are the following is happening:
1) You add a record to the store
2) You load the remote data
3) The store clears everything and loads the remote data

Bob Wilson
25 Jun 2012, 5:13 AM
Thank you for your reply.

But in the case you mention, the object state should be the last evaluated state of the object (like in your example), which in my case is AFTER the "insert" method call. :-?

Anyway : is there a way to update the store state after the manual insertion of a new item, in order to use the "final" store in - for example - a combobox ?

25 Jun 2012, 9:07 AM
If I read your code correctly it appears that you are kicking off an asynchronous store load and then inserting an item manually before the load has completed. When the load completes it will remove all previous items.

You should just need to insert the extra item after the load has completed, possibly in a load event listener.

Bob Wilson
25 Jun 2012, 12:44 PM
+1 for you...
As I'm running my server locally, I didn't think about the time to load data ! :(

Inserting my custom items in a load event solves all. ~o)
Thank you very much.