ext-- 드롭다운 목록

5686 단어 ext
1. 로컬 데이터
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>combobox.html</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <link rel="stylesheet" type="text/css" href="../ext/resources/css/ext-all.css">
	<script type="text/javascript" src="../ext/adapter/ext/ext-base.js"></script>
	<script type="text/javascript" src="../ext/ext-all.js"></script>
	<script type="text/javascript">
		Ext.onReady(function(){
			var city = [
				[1001," "],
				[1002," "],
				[1003," "],
				[1004," "],
				[1005," "],
				[1006," "]
			];
			
			var proxy__ = new Ext.data.MemoryProxy(city);
			var record = new Ext.data.Record.create(
				[
					{name:"id",type:"int",mapping:0},
					{name:"name",type:"string",mapping:1}
				]
			);
			var reader__ = new Ext.data.ArrayReader({},record);
			var store__ = new Ext.data.Store(
				{
					proxy:proxy__,
					reader:reader__,
					autoLoad:true
				}			
			);
			
			var combobox = new Ext.form.ComboBox(
				{
					renderTo:document.body,// 
					triggerAction:"all",// ,all ,query 。
					store:store__,
					displayField:"name",// 
					valueField:"id",// 。
					mode:"local",//local: ;remote: 。
					emptyText:" "// 。
				}
			);
			
			var btn = new Ext.Button(
			 {
			 	text:" ",
			 	renderTo:document.body,
			 	handler:function(){
			 		Ext.Msg.alert("","id:"+combobox.getValue()+",name:"+combobox.getRawValue());
			 	}
			 }
			);
		});
	</script>
  </head>
  
  <body>
    This is my HTML page. <br>
  </body>
</html>

2. 원격 데이터
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>pagination_combobox.html</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <link rel="stylesheet" type="text/css" href="/extjs/ext/resources/css/ext-all.css" />
    <!-- GC -->
 	<!-- LIBS -->
 	<script type="text/javascript" src="/extjs/ext/adapter/ext/ext-base.js"></script>
 	<script type="text/javascript" src="/extjs/ext/adapter/ext/ext-all.js"></script>
 	<!-- ENDLIBS -->

    <script type="text/javascript" src="/extjs/ext/ext-all-debug.js"></script>
    <script type="text/javascript">
    	Ext.onReady(function(){
    	// {total:10,data:[{'id':1,'name':' '},{'id':2,'name':' '},{'id':3,'name':' '},{'id':4,'name':' '},{'id':5,'name':' '},{'id':6,'name':' '},{'id':7,'name':' '},{'id':8,'name':' '},{'id':9,'name':' '},{'id':10,'name':' '}]}
    	
    		var proxy__ = new Ext.data.HttpProxy({url:"dept!queryDept.action"});
    		var record = new Ext.data.Record.create([
    			{
    				name:"id",type:"int",mapping:"id"
    			},
    			{
    				name:"name",type:"string",mapping:"name"
    			}]
    		);
    		
    		var reader__ = new Ext.data.JsonReader({
    			totalProperty:"total",// ( json key)
    			root:"data"// json ( json key)。
    		},record);
    		var store__ = new Ext.data.Store(
    			{
    				proxy:proxy__,
    				reader:reader__
    			});
    			
    		var dept_combobox = new Ext.form.ComboBox(
    			{
    				renderTo:document.body,
    				emptyText:" ",
    				displayField:"name",
    				valueField:"id",
    				triggerAction:"all",
    				mode:"remote",
    				store:store__,
    				pageSize:3,// 
    				listWidth:200// 。
    			}
    		);
    		
    		var button = new Ext.Button(
    			{
    				text:" ",
    				renderTo:document.body,
    				handler:function(){
    					Ext.Msg.alert(""," "+dept_combobox.getRawValue());			
    				}
    			}
    		);
    	});
    </script>

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

좋은 웹페이지 즐겨찾기