Strange extjs combobox bug when placed in toolbar and item is selected subsequent trigger clicks move list to top left corner of the browser

I came across a strange bug that occurs when you place a combobox inside a toolbar. What happens is when you click the trigger the list appears as normal under the combobox, then, if you select an item and go back to click the trigger again the list moves to the top left hand corner of the viewport. You can clear the value in the combobox and click the trigger and the list appears where it should be again. A quick fix for this problem is to override the combobox and deselect the value before expanding the picker with the code below.

Update 1

After some more testing it looks like the dropdown worked perfectly in 4.0.2 and has been broken in 4.0.7, the correction that was posted originally did not handle the additional error that occurs when the user tries to type in the box after selecting a value, and did not take into account that you might actually want to remember and reset the selected value, a more complete override has been placed below to handle all of the inconsistencies in the dropdown. Remember this strange behavior appears to only take place when the combo box is placed inside the toolbar and after the user has selected the value, in other words, it’s easy to miss this error when testing your apps.

Ext.override(Ext.form.field.ComboBox, {
		onTriggerClick: function(){	
		 var me = this;
		 me.clearValue();
      	  if (!me.readOnly && !me.disabled) {
            if (me.isExpanded) {
                me.collapse();
            } else {
                me.expand();
            }
            me.inputEl.focus();
        }
	  },
	   onKeyUp: function(e, t) {
        var me = this,
            key = e.getKey(), 
		    rv = me.getRawValue();
        if (!me.readOnly && !me.disabled && me.editable) {
            me.lastKey = key;
            // we put this in a task so that we can cancel it if a user is
            // in and out before the queryDelay elapses
            // perform query w/ any normal key or backspace or delete
            if (!e.isSpecialKey() || key == e.BACKSPACE || key == e.DELETE) {
                me.clearValue();
                me.setRawValue(key_val);
                me.doQueryTask.delay(me.queryDelay);
            }
        }
        if (me.enableKeyEvents) {
            me.callParent(arguments);
        }
    }
});

Some thoughts on Sencha Touch 2.0

Wow, I just started playing with Sencha Touch version 2 which you can now download, and which comes with an extjs 4 style API on the sencha website, and I was so impressed I spent a few hours this weekend ditching my entire ICD10 app that was being written in jquery mobile. Why? The one word answer is speed, both in development time, and performance. Unlike version 1 I could hardly tell if I was coding extjs or touch, they seemed to work and act the same, this is a great plus for someone with a 9 – 5 in extjs coding. As far as performance is concerned take a look at the two apps side by side, then try to do a search for a medical term like ‘strep’ and see how they both respond. Now, imagine this difference playing out on a mobile device and not your desktop.

jquery mobile ICD 10 app

Sencha Touch 2 ICD 10 app

In addition, it looks like phonegap was purchased by Adobe, and it is now easier than ever to package and create native app files from your html5 / javascript application code, although the ‘free’ aspect of it has fallen by the wayside, the time saved is well worth the cost.

Grouping on multiple columns in extjs 4

Yes, you can still add multiple columns to a grouping grid, and it’s not that hard, you just have to look in the store!

To add a second or even third column to an extjs grid all you now have to is add the extra columns in the store’s getGroupString property. The code below illustrates the addition of a second value when the group string equals some_property.

var some_data_store = Ext.create('Ext.data.Store', {
     storeId:'some_data_store',
     groupField:'some_property',
    getGroupString: function(instance) {
	   var group = this.groupers.first();
  	   if (group) {
       	      if (group.property == 'some_property') {
		 return instance.get(group.property) + ' (' + instance.get('my_second_property') + ') ';
	    }
	  return instance.get(group.property);
		   }
		   return '';
		},
	model:'some_data_model',
	autoLoad:true,
	proxy: {
        	type: 'ajax',
        	url : 'some_url.php',
        	reader: {
            	type: 'json',
            	root: 'data'
        }
}
});

Ext Grid Grouping summary collapse all, expand all, and collapse all but the top group overrides for extjs4

I usually use grouping grids in conjunction with the summary feature so I can store blocks of data together and give the user a quick set of totals. I find that leaving one set of data open allows the user to grasp the fact that you can drill through the information, and this of course looks a lot better than starting with a grid full of collapsed groups. To open the top group and collapse all of the remaining groups on load I implement the following override to the grid grouping summary view ( this can also be easily applied to the grouping view as well), also, if you prefer to give users the ability to expand or collapse all of the groups at the same time via a one click button, just call the collapseAll or expandAll events that have now been added to the grouping view.

Ext.override(Ext.grid.feature.GroupingSummary, {
   collapseAll: function() {
     var self = this, groups = this.view.el.query('.x-grid-group-body'); 
     Ext.Array.forEach(groups, function (group) {         
	self.collapse(Ext.get(group.id));     
	   }); 
  },
    expandAll: function() {
       var self = this, groups = this.view.el.query('.x-grid-group-body');    
       Ext.Array.forEach(groups, function (group) {     
	self.expand(Ext.get(group.id));     
	   }); 
  },
    collapseAllButTop: function() {
        var self = this, groups = this.view.el.query('.x-grid-group-body'); 
        Ext.Array.forEach(groups, function (group) {         
	self.collapse(Ext.get(group.id));     
	   }); 
        if(groups.length > 0){
        this.expand(Ext.get(groups[0].id));
         }
}
});	

After placing the code above at the beginning of your javascript you will need to assign an id to all of the groupingsummary features that you wish to access this new event. An example is below. The reason for this is to allow you to use the ext table method getFeature [http://docs.sencha.com/ext-js/4-0/#!/api/Ext.view.Table-method-getFeature] to reference the groups.

features: [{
      groupHeaderTpl: ' {name} Expense  Summary ',
      ftype: 'groupingsummary',
      id:'my_groupingsummary',
      startCollapsed:true
    }]

Now you just have to add a callback function to the store load event (my_grid_data is the store in this instance) like this to collapse all but the first group in your grid.

my_grid_data.load({
    callback:function(){					
my_grid.getView().getFeature('my_groupingsummary').collapseAllButTop();	
}
});

A look at your most important design decision – font, and size

Let’s take a code break for a minute and discuss fonts, target audiences, and why a screen will never equal a piece of paper. When you are designing your pages, the choices that you make regarding fonts and font sizes are some of the most important. Why? First, computer screens by design are going to be harder on the eyes than paper, as paper reflects light, where computer screens emit light and are constantly being refreshed, this means that as a designer you should make every effort to ease the strain and make your site as readable as possible. Take a look at the image below:

The x-size, which is literally the size of the small x in the font family, where the point size is the distance from the top of the ascender to the bottom of the descender. This is the reason that some fonts just look bigger than others when you place them in your code using the same point size in your CSS. For a good example take a look below:

Hey I’m 12 point arial, how do I look?
Hey I’m 12 point times new roman, I know I was designed for newspapers, but how do I look on the screen?
Hey I’m 12 point veranda, how do I look on the screen?
Hey I’m 12 point tahoma, how do I look on the screen?

There you have it, not only does size matter, font style plays an equally important role, but that’s not all …

Notice that some of the fonts are Serif, with the small lines on the ends of the characters, and some are Sans Serif, without the decoration. So what does this mean to the programmer? For the web designer, it’s easier on your audience if you go with a sans-serif font style, which is the opposite of traditional printing. The reason is the dots per inch or dpi on a screen is much less than the dpi when printing, the fonts seem to scale better.