We often need to do deep copies of Javascript objects so that we can modify the copy without it affecting the original. I have created the following clone function that does this quickly and easily; however, it does have limitations. If you clone an instance of, lets say, an Ext.Panel, Javascript’s instanceof function will fail to recognize it as an instance of Ext.Panel. From what I can gather, this is because the Javascript engine has some kind of internal reference to an object’s constructor and instanceof doesn’t actually look at the constructor we are able to modify… lets look at an example so it is more clear:
Monthly Archive for May, 2008
A question appeared on the ExtJS forums today regarding how to bind event listeners on multiple links that are generated from the server. Bind an event listener to each link, right? Wrong! This is wrong in the sense that it wastes system resources and is unnecessary. Can you imagine how much resources TreePanel would take up if it bound a click listener on every single node element!? Oh wait… that’s probably what you though it did :-). But it doesn’t.
Continue reading ‘ExtJS Performance - Element click events’
Aaron Conran of ExtJS just published a post today recommending using namespaces to organize your Javascript code. I have a rewrite of the Ext.namespace function that I find a little more useful.

Check out the first post in this series: Stark Industries - Entrance into Madness
One of the things I learned at Stark Industries is how to do your job without the proper tools available… I was like MacGyver. Continue reading ‘Stark Industries - Doing your job, MacGyver Style’
A TEMPORARY table is a table that is bound to a connection and is dropped when that connection is closed. It seems like this would just be a normal table with some meta data attached to it indicating the connection it is bound to. I suppose for some reason it is more complicated than that… seems unnecessarily so…
Anyways, the limitation is that you cannot refer to a given temporary table more than once in a single query. If you do you will get a “Can’t reopen temporary table” error. So, for instance you cannot insert into a temporary table some data that you select from it in in the same query. This limitation has bit me several times.
The bug is here: http://bugs.mysql.com/bug.php?id=10327
Continue reading ‘MySQL Temporary Table reference limitation’
I consider myself to be an expert in ExtJS. However, there is one component that I have to lookup how to use just about every single time I use it: Ext.form.ComboBox. For me, the default implementation just doesn’t cut it. There are a number of problems I have all the time:
- Forgetting to set “mode” to remote when I provide a store that is obviously “remote”
- Drop-down list width sometimes is smaller than the combo box itself
- I hate having to setup a store every time I need a remote ComboBox
- After the store loads, the value in the input box is not automatically replaced with displayValue
Maybe these issues are more my issues, but I maintain that ComboBox is one of poorer ExtJS components. Here is my replacement:
Please see the new code here: Update to ComboBox Replacement
Use it like this:
var combo1 = new com.succinctllc.form.ComboBox({ displayField:'name', valueField:'id', url:"/path/to/dataSource" }); |
Edited to set lastQuery properly so ComboBox does not load the store twice when autoLoad is set to true (default).
This is going to be my first non technical series. I really want to illustrate some insanely frustrating, almost funny (if it wasn’t so maddening) experiences. If you guys have ever read The Daily WTF, this is my personal experience with some WTF’s.
After graduation I took a job at… we will call it Stark Industries. I spent nearly 6 months waiting for my security clearance. During this time I read documentation, did code reviews, and watched A LOT of YouTube. Continue reading ‘Stark Industries - Entrance into Madness’
There was a link on Ajaxian a while ago about Javascript2 and Generics. Everyone was either up in arms that Javascript2 was going to implement generics in the first place or that the syntax was weird with the dot in there. I am of the second camp. I did some research and discovered a little more information on why this decision was made. Take a look at the javascript generics syntax discussion:
-
Angle brackets are hard to parse because they are not normally used as brackets and because ECMAScript does not clearly delineate “type” context expressions from “other” expressions.
-
For annotations we can perhaps fix the parsing problem by introducing syntactic constraints on type expressions.
-
With parameterized function types, we will need unbounded lookahead: one can’t disambiguate until one sees the closing angle bracket. This complicates the parser substantially.
-
So, the reason this syntax was chosen is to ease parser developer’s lives. The primary reason being that the parser cannot tell whether a < is the start of a parametrized definition or if it is just a less-than-sign. This is why they tentatively decided on prefixing the dot on there. I suppose I understand this, especially with a type un-safe language like Javascript. I am still hoping they choose to make the parser developer’s lives more difficult so my life can be easier :-).
If you read on in the discussion someone states that they might choose to drop the dot later. (fingers crossed) Honestly though, if I get a decent Javascript IDE out of these language changes then I am fine with the dot.
In our application at ControlPath, we have a pretty complex permission system. Well, imagine a permission system based off of a cyclical graph of 30,000 nodes with multiple levels of inheritance rules and you just begin to scratch the surface. I recently rewrote the permission rebuild caching system into recursive stored procedures. This improved performance from 45 minutes… to 45 seconds. There are a bunch of tricks I employed to get this kind of speedup, but today I am going to share 2 of the simplest ones with you… Continue reading ‘MySQL Stored Procedure Performance Tricks’
This is purely conceptual at this point but I would love to have this feature. It would be similar to TrimQuery but be based on Ext Stores. I would love to be able to do this:
var joinedStore = new Ext.data.QueryStore({ query: "SELECT p1.name as parentName, p2.name as childName, IF(p1.id=1,'parent','child') as relationshipType "+ "FROM relationship r "+ "JOIN people p1 ON (r.parentId = p1.id) "+ "JOIN people p2 ON (r.childId = p2.id) "+ "WHERE p1.id = 1 OR p2.id = 1" }); |
[Edit]
Let me preface this with the fact that this is NOT server side SQL. This SQL never gets sent to the server. This is a very simple client side implementation that is only used for joining together data from multiple stores into an intermediary store which is useful for displaying grids that don’t match your server side data model. It saves you from having to create one-off data providers for these grids and having to migrate changes to your other stores by hand.
[/Edit]
Continue reading ‘ExtJS - QueryStore & Store Query Language’