Showing posts with label Prototype. Show all posts
Showing posts with label Prototype. Show all posts

Wednesday, 30 January 2013

Convert String to Title case in Javascript

Hi,
Sometimes we need to convert user Name to proper casing, for that we can use below method.

i.e. JoHn METHEW will be converted to John Methew

/**
 *  Provie toProperCase method to string Class
 */
String.prototype.toProperCase = function() {
 return this.replace(/\w\S*/g, function(txt) {
  return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
 });
};

Usage:

"JoHn METHEW".toProperCase()

Friday, 3 February 2012

Itemselector Height in ExtJs4

It seems like in ExtJS4.0.2a, we can not modify the height directly. ( height:) will not work. As height has been initialized to 200 by default..

To Assign your own height you have to override the onRender method of ItemSelector.js

commonConfig = {
displayField: me.displayField,
valueField: me.valueField,
dragGroup: ddGroup,
dropGroup: ddGroup,
flex: 1,
hideLabel: true,
height : (this.height || 200)
}