日期:2014-05-16  浏览次数:20505 次

ExtJS--10.4 Ext工具类 Ext.util.Format
<!DOCTYPE html>
<html>
<head>
	<title>Ext.util.Format</title>
	<meta name="content-type" content="text/html" charset="UTF-8">
	<link rel="stylesheet" type="text/css" href="../extjs4/resources/css/ext-all.css">
	<script type="text/javascript" src="../extjs4/bootstrap.js"></script>
	<script type="text/javascript">
		Ext.onReady(function(){
/** 1. ellipsis( value, length, [word] ) : String */
			Ext.get("btn01").on("click",function(){
				var input = Ext.getDom("input01");
				var output = Ext.getDom("input02");
				output.value = Ext.util.Format.ellipsis(input.value, 10);
			});
/** 2. capitalize( string ) : String */
			Ext.get("btn02").on("click",function(){
				var input = Ext.getDom("input03");
				var output = Ext.getDom("input04");
				output.value = Ext.util.Format.capitalize(input.value);
			});
/** 3. date( value, [format] ) : String */
			Ext.get("btn03").on("click",function(){
				var output = Ext.getDom("input05");
				output.value = Ext.util.Format.date(new Date(),"Y年m月d日");
			});
/** 4. substr( value, start, length ) : String */
			Ext.get("btn04").on("click",function(){
				var input = Ext.getDom("input06");
				var output = Ext.getDom("input07");
				output.value = Ext.util.Format.substr(input.value,0,4);
			});
/** 5. lowercase( value ) : String */
			Ext.get("btn05").on("click",function(){
				var input = Ext.getDom("input08");
				var output = Ext.getDom("input09");
				output.value = Ext.util.Format.lowercase(input.value);
			});
/** 6. number( v, format ) : String */
			Ext.get("btn06").on("click",function(){
				var input = Ext.getDom("input10");
				var output = Ext.getDom("input11");
				output.value = Ext.util.Format.number(input.value,"0,000.00");
			});
/** 7. nl2br( v ) : String */
			Ext.get("btn07").on("click",function(){
				alert(Ext.util.Format.nl2br("Ivan\nHuang"));
			});
		}); 
	</script>
</head>
<body>
	<div style="text-align: center;">
		<div>
			<input type="text" id="input01" value="www.upscat.com.cn">
			<input type="text" id="input02" readonly="readonly" disabled="disabled">
			<input type="button" id="btn01" value="demo01">
		</div>
		<div>
			<input type="text" id="input03" value="ivan">
			<input type="text" id="input04" readonly="readonly" disabled="disabled">
			<input type="button" id="btn02" value="demo02">
		</div>
		<div>
			<input type="text" id="input05" readonly="readonly" disabled="disabled">
			<input type="button" id="btn03" value="demo03">
		</div>
		<div>
			<input type="text" id="input06" value="ivan_Huang">
			<input type="text" id="input07" readonly="readonly" disabled="disabled">
			<input type="button" id="btn04" value="demo04">
		</div>
		<div>
			<input type="text" id="input08" value="WWW.UPSCAT.COM.CN">
			<input type="text" id="input09" readonly="readonly" disabled="disabled">
			<input type="button" id="btn05" value="demo05">
		</div>
		<div>
			<input type="text" id="input10" value="1234567890">
			<input type="text" id="input11" readonly="readonly" disabled="disabled">
			<input type="button" id="btn06" value="demo06">
		</div>
		<div>
			<input type="button" id="btn07" value="demo07">
		</div>
	</div>
</body>
</html>

?