Common Extjs Tools: Extjs.util.Format Use Method _extjs

Source: Internet
Author: User
Tags lowercase mixed string format
Copy some common tools for easy search
----------string
Ext.util.Format.capitalize (string str);//capitalize the first letter
Ext.util.Format.ellipsis (string value, number length), or intercepting the specified length character, automatically adds an ellipsis ' ... ' at the end.
Ext.util.Format.htmlEncode (string value); Encode the text
Lowercase (string value);//lowercase
Stripscripts (Mixed value);//Delete all script tags
Striptags (Mixed value);//Delete all labels
substr (value, start, length)
Trim (value)

----------Date
Ext.util.Format.date (mixd value, [String Format]); such as: Ext.util.Format.date (new Date (), ' y-m-d ') =>2012-03-19
Ext.util.Format.dateRenderer (string Format);//used exclusively for Ext.grid.Gridpanel, Columnmodel

---------Dormitory judgment
DefaultValue (Mixed value, string defalutvalue);//If the first argument is empty, the second is returned, and vice versa.
UNDEF (Mixed value;//Returns an empty string if value equals NULL, otherwise return value

========== Extended function
1, Createcallback () creates a callback function for the current function, such as:
Copy Code code as follows:

var sayhi = function (name) {
Alert (' Hi ' +name);
}
New Ext.button ({
Text: ' Say hi ',
Handler:sayHi.createCallback (' Jinshan ')
});

The role of Createcallback is to set default parameters for existing parameters. In the previous example, the ' Jinshan ' was set to the corresponding callback function when Createcallback was used, and the parameter was passed to Sayhi () after the button was clicked.

2, CreateDelegate () creates the proxy function for the current function.
Such as:
Copy Code code as follows:

var sayhi = function (name) {
alert (Name-this.text); This.text represents the text value of the BTN function say Hi,
}
var btn = new Ext.button ({
Text: ' Say Hi '
});
Btn.on (' Click ', Sayhi.createdelegate (btn, [' JISNH ']);

This creates the proxy, Sayhi points to the btn. If BTN is changed to another object, Sayhi will automatically go to another object.


3, Createinterceptor (fun, scope); Set interceptors for the current function, similar to the AOP concept. Such as:
Copy Code code as follows:

var sayhi = function (name) {
alert (name);
}
Sayhi (' 1 ');
var Sayhito = sayhi.createinterceptor (function (name) {
return name = = ' 2 ';
});
Sayhito (1);//No hint
Sayhito (2);//Eject 2

The interceptor executes before the original function executes and executes the original function only if the interceptor returns TRUE.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.