日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

Extjs---grid的使用

系統 2057 0

一個簡單的grid的創建

html代碼:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Grid示例</title> 
<link rel="stylesheet" type="text/css" href="ext4/resources/css/ext-all.css" /> 
    <script type="text/javascript" src="ext4/ext-all.js"></script> 
    <script type="text/javascript" src="js/grid.js"></script> 
</head> 

<body> 
<div id="grid"></div> 
</body> 
</html> 
  

grid.js代碼

    //預加載
Ext.require(
		[
		 	'Ext.grid.*',
		 	'Ext.data.*'
		 ]
		 
);

Ext.onReady(
		function(){
			//創建Model
			Ext.define(
					'MyData',
					{
						extend:'Ext.data.Model',
						fields:[
						        {name:'name',mapping:'name'},
						        {name:'sex',mapping:'sex'},
						        {name:'age',mapping:'age'}
						]
					}
			)
			//創建數據源
			var store = Ext.create(
					'Ext.data.Store',
					{
						model:'MyData',
						proxy:{
							type:'ajax',
							url:'data/mydata.json',
							reader:{
								type:'json',
								root:'items'
							}
						},
						autoLoad:true
					}
			);
			
			//創建grid
			var grid = Ext.create('Ext.grid.Panel',{
					store:store,
					columns:[
					         {text:'姓名',width:120,dataIndex:'name',sortable:true},
					         {text:'性別',width:120,dataIndex:'sex',sortable:true},
					         {text:'年齡',width:120,dataIndex:'age',sortable:true}
					],
					height:400, 
			        width:480, 
			        x:20, 
			        y:40, 
			        title: 'ExtJS4 Grid示例', 
			        renderTo: 'grid', 
			        viewConfig: { 
			            stripeRows: true 
			        } 
				}
			)
		}
)


  

mydata.json代碼:

    {
	 "items": [  
        {  
            "name": "小黑",  
            "sex": "男",  
            "age":25, 
        },  
        {  
            "name": "哈哈",  
            "sex": "男",  
            "age":31, 
        }, 
        {  
            "name": "好好",  
            "sex": "男",  
            "age":30, 
        }
	]
}
  

效果圖:

Extjs---grid的使用



多表頭grid

只需要修改grid的創建代碼即可:


    var grid = Ext.create('Ext.grid.Panel',{
					store:store,
					
					columns:[
					         {
					        	 text:'基本信息',
					        	 columns:[
									         {text:'姓名',width:120,dataIndex:'name',sortable:true},
									         {text:'性別',width:120,dataIndex:'sex',sortable:true},
									         {text:'年齡',width:120,dataIndex:'age',sortable:true}
									]
					         },{
					        	 text:'日期',
					         }
					],
					height:400, 
			        width:480, 
			        x:20, 
			        y:40, 
			        title: 'ExtJS4 Grid示例', 
			        renderTo: 'grid', 
			        viewConfig: { 
			            stripeRows: true 
			        } 
				}
			)
  

效果圖:

Extjs---grid的使用

Extjs---grid的使用


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 齐河县| 拜泉县| 北海市| 中山市| 阿拉善左旗| 六枝特区| 麻阳| 昭苏县| 永登县| 宜兴市| 颍上县| 苗栗县| 贵阳市| 浦县| 通化县| 孝昌县| 牡丹江市| 丹阳市| 江都市| 平安县| 赣榆县| 惠东县| 宜黄县| 临湘市| 武汉市| 宁陵县| 新源县| 南昌市| 武隆县| 澄江县| 云安县| 平安县| 赣榆县| 板桥市| 博野县| 安阳县| 沁源县| 会东县| 黔东| 朝阳区| 乌拉特后旗|