(15)ExtJS之Ext.form.field.Spinner微调字段

JS文件:

//7:Spinner:微调字段
Ext.onReady(function(){
	
	new Ext.form.Panel({
		title:'Ext.form.field.Spinner示例',
		bodyStyle:'padding:5',
		frame:true,
		height:70,
		width:250,
		renderTo:'form',
		defaults:{//统一设置表单字段默认属性
			labelSeparator:':',//分隔符
			labelWidth:70,//标签宽度
			width:200,//字段宽度
			labelAlign:'left'//标签对齐方式
		},
		items:[{
			xtype:'spinnerfield',
			fieldLabel:'微调字段',
			id:'salary',//组件id
			value:100,
			onSpinUp:function(){
				var salaryCmp=Ext.getCmp('salary');//通过组件id获得组件对象
				//增加默认值
				salaryCmp.setValue(Number(salaryCmp.getValue())+1);
			},
			onSpinDown:function(){
				var salaryCmp=Ext.getCmp('salary');
				//减少默认值
				salaryCmp.setValue(Number(salaryCmp.getValue())-1);
			}
			
		}]
	});
	
});







JSP文件:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'JS1.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!-- extjs的样式文件 -->
	<link rel="stylesheet" type="text/css" href="js/extjs/resources/css/ext-all.css">
	<!-- extjs的核心文件 -->
	<script type="text/javascript" charset="utf-8" src="js/extjs/ext-all-debug.js"></script>
	<!-- 国际化文件 -->
	<script type="text/javascript" charset="utf-8" src="js/extjs/ext-lang-zh_CN.js"></script>
	
	<script type="text/javascript" charset="utf-8" src="base/009_text.js"></script>


  </head>
  
  
  <body > 
  </body>
</html>


 

你可能感兴趣的:((15)ExtJS之Ext.form.field.Spinner微调字段)