EXT core API (7)-Ext. keynav/keymap/JSON/format/delayedtask/taskrunner/textmetrics/xtemplate

Source: Internet
Author: User
Tags encode string
Ext. keynav
The keynav class of ext can provide a simple key processing method for the Ext. element.
Example:
VaR El = ext. Get ("textarea ");
New Ext. keynav (El ,{
"Left": function (e ){
Alert ("left key down ");
},
Scope: El
}
);
Its behavior is similar to that of keymap, but its function is much weaker than that of keymap. It can only process the following defined keys
Enter/left/right/up/down/TAB/esc/Pageup/Pagedown/del/home/end
Sympathize With keynav

There are only three methods, which do not need to be explained.
Keynav (mixed El, object config)
Disable (): void
Enable (): void

Ext. keymap class
The most important thing is that the key definition is more flexible.
Example: In the above example, if keymap is used for writing, it may be
VaR El = ext. Get ("textarea ");
New Ext. keymap (El ,{
Key: Ext. eventobject. Left,
FN: function (e ){
Alert ("left key down ");
},
Scope: El
}
);

Method
Keymap (mixed El, object config, [String eventname])
Construction, similar to keynav, but more flexible
It is {
Key: String/array, // It Can Be A number, character, ext. eventobject. Left, or an array composed of them.
Shift: Boolean, // press the ctrl key?
CTRL: Boolean,
ALT: Boolean,
FN: function, // call back method
Scope: object // range
} Such objects or their Arrays
For example, {key: 10}, {key: [10, 13]}, {key: '\ t'}, {key: 'abcd'}, {key: ext. eventobject. left} is a legal definition.

Addbinding (Object/array config): void
Add a new binding action. For more information, see constructor.

Disable (): void
Enable (): void
Isenabled (): Boolean
Allow, static, and status queries

On (number/array/object key, function FN, [object scope]): void
Only add a shortcut for addbinding processing, but I personally feel that it is not easy.

Ext. util. JSON
It's the turn of the well-known JSON. Unfortunately, the JSON object function provided by ext is weak, and there are only two methods for the encode primary decode.
It can only encode string/array/date. At least the xml2json/json2xml method is required.

Ext. util. Format
Mainly provides some formatting Methods

Capitalize (string value): String
Uppercase letters

Date (mixed value, [string format]): String
Format the date output, or use the date. Format method.

Daterenderer (string format): Function
Returns a method for formatting a date using the specified format.

Defaultvalue (mixed value, string defaultvalue): String
If the value is undefined or a Null String, defaultvalue is returned.

Ellipsis (string value, number length): String
If the length of the value exceeds the length, take the first length-3 and replace it with.... for Chinese, it is still a garbage function. The length of the string used is not a byte length.

Filesize (number/string size): String
The simple format file length is xxxbytes xxxkb xxxmb, no GB yo

Htmlencode (string value): String
Htmldecode (string value): String
HTML encoding and decoding, replace & <> "with & amp; & lt; & gt; & quot;

Lowercase (string value): String
Convert value to lowercase letters

Stripscripts (mixed value): String
Remove script labels

Striptags (mixed value): String
Remove HTML tags

Substr (string value, number start, number length): String
Substring

Trim (string value): String
Remove spaces at the beginning and end

UNDEF (mixed value): mixed
If the value is not defined, an empty string is returned. Otherwise, the value itself is returned.

Uppercase (string value): String
Convert to full capital

Usmoney (number/string value): String
Converted to USD

Ext. util. delayedtask
Provides a simple alternative to setTimeout.

There are only three public methods.
Delayedtask ([function FN], [object scope], [array ARGs])
Delay (number delay, [function newfn], [object newscope], [array newargs]):
Cancel (): void
For a simple example, if
VaR task = new Ext. util. delayedtask (ext. emptufn );
Tasks. Delay (1000 );
Task. Cancel ();

Ext. util. taskrunner
The enhanced version of delayedtask can provide multi-thread timing services,
Example:
VaR task = {
Run: function (){
Ext. Fly ('clock '). Update (new date (). Format ('G: I: s '));
},
Interval: 1000
}
VaR runner = new Ext. util. taskrunner ();
Runner. Start (task );

The four methods are simple.
Taskrunner ([number interval])
Start ([object task]): Object
Stop (Object task): Object
Stopall (): void

Ext. util. textmetrics
This class is mainly used to prepare the correct height and width of the block text.
Example:
VaR metrics = ext. util. textmetrics. createinstance ('div ');
Metrics. setfixedwidth (100 );
VaR size = metrics. getsize ("People's Republic of China, People's Republic of China, People's Republic of China ");
Ext. MessageBox. Alert ("getsize", String. Format ("width: {0} PX \ theight: {1} PX", size. Width, size. Height ))

Method
BIND (string/htmlelement El): void
Bind to El

Createinstance (string/htmlelement El, [number fixedwidth]): Ext. util. textmetrics. Instance
Create a textmetrics instance for El

Getheight (string text): Number
Getsize (string text): Object
Getwidth (string text): Number
Get size

Measure (string/htmlelement El, string text, [number fixedwidth]): Object
Measure the size of text to be occupied in El

Setfixedwidth (number width): void
Set the specified width

Ext. xtemplate
enhanced templates support more functions. Although there are not many methods, it is really troublesome to use them. However, we do not recommend that you learn such custom syntax, it is better to use XSLT
In addition, although the xtemplate namespace is under Ext, the source file is placed in the util directory
xtemplate (string/array html)
xtemplate. from (string/htmlelement El): ext. xtemplate
apply (): void
applytemplate (Object values): String
compile (): function
these methods Ext. description is provided in the template.

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.