PDA

View Full Version : Grid drag ddText enhancement



mailme_gx
9 Sep 2009, 11:51 PM
Hi All

There is a limitation in the way the ddText is formatted "{1} selected row{1}" if there is more than one row selected it reads "2 selected rows" which is fine for English but not compatible for other languages. here is my fix:



Ext.ux.data.GridViewPanel = Ext.extend(Ext.grid.GridPanel, {
getDragDropText : function(){
var count = this.selModel.getCount();
// return String.format(this.ddText, count, count == 1 ? '' : 's'); // <-- original code
var txt = this.ddText;
if(count > 1)
txt = this.ddTextPlural || this.ddText + 's'; // <-- backward compatible

return String.format(txt, count);
}

});


Hope someone finds this usefull, in order to apply it the two attributes can be specified as:



this.grid = new Ext.ux.data.GridViewPanel({
store: mystore,
ddGroup: 'grid-dd',
ddText: 'only {0} row selected',
ddTextPlural: 'you have selected {0} rows '
});


Lame example but as I said in other languages (at least greek) both the words 'selected' and 'rows' need to be plural.

Regards

GX