Ext Js4 CheckBox 학습 및 실례

1: 프로그램 코드
 
<%@ 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>CheckBox</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">

	<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" src="ExtJS4/ext-all.js" ></script>
    <script type="text/javascript" src="ExtJS4/locale/ext-lang-zh_CN.js"></script>	
    
     <script type="text/javascript" >
      Ext.onReady(function() {
        Ext.create('Ext.form.Panel', {
	    bodyPadding: 10,
	    width      : 300,
	    title      : ' ',
	    items: [
	        {
	            xtype      : 'fieldcontainer',
	            fieldLabel : ' ',
	            defaultType: 'checkboxfield',
	            items: [
	                {
	                    boxLabel  : ' ',
	                    name      : 'hobby',
	                    inputValue: '1',
	                    id        : 'sing'
	                }, {
	                    boxLabel  : ' ',
	                    name      : 'hobby',
	                    inputValue: '2',
	                    checked   : true,
	                    id        : 'dance'
	                }, {
	                    boxLabel  : ' ',
	                    name      : 'hobby',
	                    inputValue: '3',
	                    id        : 'read'
	                }
	            ]
	        }
	    ],
	    bbar: [
	        {
	            text: ' ',
	            handler: function() {
	                var checkbox = Ext.getCmp('sing');
	                checkbox.setValue(true);
	            }
	        },
	        '-',
	        {
	            text: ' ',
	            handler: function() {
	                var checkbox1 = Ext.getCmp('sing'),
	                    checkbox2 = Ext.getCmp('dance'),
	                    checkbox3 = Ext.getCmp('read');
	
	                checkbox1.setValue(true);
	                checkbox2.setValue(true);
	                checkbox3.setValue(true);
	            }
	        },
	        {
	            text: ' ',
	            handler: function() {
	                var checkbox1 = Ext.getCmp('sing'),
	                    checkbox2 = Ext.getCmp('dance'),
	                    checkbox3 = Ext.getCmp('read');
	
	                checkbox1.setValue(false);
	                checkbox2.setValue(false);
	                checkbox3.setValue(false);
	            }
	        }, 
	        {
	            text: ' ',
	            handler: function() {
	                 var checkbox1 = Ext.getCmp('sing'),
	                    checkbox2 = Ext.getCmp('dance'),
	                    checkbox3 = Ext.getCmp('read');
	                    
	                if(checkbox1.getValue()) {
	                     checkbox1.setValue(false);
	                     
	                } else {
	                      checkbox1.setValue(true);
	                      
	                }
	                if(checkbox2.getValue()) {
	                    checkbox2.setValue(false);
	                    
	                } else {
	                     checkbox2.setValue(true);
	                     
	                }
	                if(checkbox3.getValue()) {
	                     checkbox3.setValue(false);
	                     
	                } else {
	                      checkbox3.setValue(true);
	                      
	                }
	            }
	        }
	    ],
	    renderTo: Ext.getBody()
	});
        
     });
        
   </script>
  </head>
  <body>
  </body>
  
</html>

2: 프로그램 효과도
 

좋은 웹페이지 즐겨찾기