I recently ran into a situation where I had multiple instances of the same store that were each taking on the characteristics of the other store's proxy.  The scenario was similar to the following example:

Ext.define("BadSeed", {
extend : "Ext.data.Model",
proxy : {
type : "rest",
url : "rest/badseed"
},
fields : [...]
}
});

Ext.define("NickCaveBandMembers", {
extend : "Ext.data.Store",
model : "BadSeed"
});

In general, I like to define my proxy on the model and let the store just use the model's proxy for communication.  This allows me to keep my code DRY.  Who wants to define the same proxy in multiple places when once is enough?

This works great... until you need to create two instances of the store and make modifications to one of the store's proxies at run time.  The following example shows the problem:

var currentMembers = Ext.create("NickCaveBandMembers");
var allMembers = Ext.create("NickCaveBandMembers");

currentMembers.getProxy().extraParams = {
active : true
}
var showMembers = function(title, members) {
console.log(title);
Ext.each(members, function(member) {
console.log(member.get("lastName");
});
}
currentMembers.load({
callback : function(members) {
showMembers("CURRENT MEMBERS", members);
}
});
allMembersMembers.load({
callback : function(members) {
showMembers("ALL MEMBERS", members);
}
});

The output for this ends up very different than you would expect:

CURRENT MEMBERS
Adamson
Wydler
Casey
Savage
...
ALL MEMBERS
Adamson
Wydler
Casey
Savage
...

After a few minutes of digging, this began to make perfect sense.

What is happening is very simple.  When you define the model, a single instance of the proxy is created to be used for all instances of the model.  If it didn't work this way, you could have tens... hundreds of instances of the exact same proxy created with no benefit.

When you create instances of your store, they don't create a new proxy based on your model's proxy configuration object... they use the same single proxy instance associated with the model.  Any changes to a proxy for one store instance... cause the same changes to happen for the other instances.

Fortunately, the solution to this is very simple.  Just place the proxy configuration directly on the store as well.:

Ext.define("BadSeed", {
extend : "Ext.data.Model",
proxy : {
type : "rest",
url : "rest/badseed"
},
fields : [...]
}
});

Ext.define("NickCaveBandMembers", {
extend : "Ext.data.Store",
model : "BadSeed",
proxy : {
type : "rest",
url : "rest/badseed"
}
});

You may want to define that proxy object somewhere else (once again, to keep it DRY), but for the purposes of this example it demonstrates the simple fix to situations where multiple store instances need their own proxies.

Posted
AuthorBob Obringer

 There should be a more obvious way to do this (or, the border should automatically be hidden when the column headers are hidden), but the solution is simple.

Just add the following to your gridpanel configuration:

bodyCls : "x-docked-noborder-top"

This is for ExtJS 4.x (but I believe also worked in 3.x).  Fingers crossed that the Sencha guys give us a more elegant solution for 5.0 when it arrives in 2014.

Posted
AuthorBob Obringer

Since upgrading to Mavericks, I've been trying to keep my system clean and streamlined as possible.  This includes a move to homebrew as my package manager.  It's not as mature as macports, but it's certainly easier to work with.  This is a layer of my operating system that I never want to think about, so simplicity is my number one priority.  I may still need macports at some point, but for now, I'm sticking with simple.

One of the things I was missing during the first few days on Mavericks was the fish shell.  It's been my replacement for the default bash shell for a few years now.   As of today, Fish 2.1.0 has been released with full Mavericks support and a homebrew installer.

Getting up and running couldn't be easier...

First, install homebrew if you haven't already:

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

Next, install fish:

brew install fish

Next, you need to add fish to the list of shells available on your system, and configure it as your default shell: 

echo "/usr/local/bin/fish" | sudo tee -a /etc/shells
chsh -s /usr/local/bin/fish

That's it... you're all set. 

Posted
AuthorBob Obringer