职业IT人-IT人生活圈

 找回密码
 成为会员
搜索
查看: 5575|回复: 20

extjs4学习笔记大全

    [复制链接]
Jethro 发表于 2011-6-4 15:26 | 显示全部楼层 |阅读模式
本帖最后由 Jethro 于 2011-6-4 15:48 编辑

ExtJS4学习笔记(一)---window的创建

Extjs4,创建Ext组件有了新的方式,就是Ext.create(....),而且可以使用动态加载JS的方式来加快组件的渲染,我们再也不必一次加载已经达到1MB的ext-all.js了,本文介绍如何在EXTJS4中创建一个window。

代码如下:
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>窗口实例--www.51myit.com</title>
  6. <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
  7. <script type="text/javascript" src="../../bootstrap.js"></script>
  8. <script type="text/javascript" src="../../locale/ext-lang-zh_CN.js"></script>
  9. <script type="text/jscript">
  10. Ext.require('Ext.window');
  11. Ext.onReady(function(){
  12.   Ext.create('Ext.Window',{
  13.     width:400,
  14.     height:230,
  15.     //X,Y标识窗口相对于父窗口的偏移值。
  16.     x:10,
  17.     y:10,
  18.     plain: true,
  19.     //指示标题头的位置,分别为 top,bottom,left,right,默认为top
  20.     headerPosition: 'left',
  21.     title: 'ExtJS4 Window的创建,头在左'
  22.   }).show();
  23.    
  24.   Ext.create('Ext.Window',{
  25.     width:400,
  26.     height:230,
  27.     x:500,
  28.     y:10,
  29.     plain: true,
  30.     //指示标题头的位置,分别为 top,bottom,left,right,默认为top
  31.     headerPosition: 'right',
  32.     title: 'ExtJS4 Window的创建,头在右'
  33.   }).show();
  34.    
  35.   Ext.create('Ext.Window',{
  36.     width:400,
  37.     height:230,
  38.     x:10,
  39.     y:300,
  40.     plain: true,
  41.     //指示标题头的位置,分别为 top,bottom,left,right,默认为top
  42.     headerPosition: 'bottom',
  43.     title: 'ExtJS4 Window的创建,头在底'
  44.   }).show();
  45.   var win = Ext.create('Ext.Window',{
  46.     width:400,
  47.     height:230,
  48.     x:500,
  49.     y:300,
  50.     plain: true,
  51.     //指示标题头的位置,分别为 top,bottom,left,right,默认为top
  52.     headerPosition: 'top',
  53.     title: 'ExtJS4 Window的创建'
  54.   });
  55.   win.show();
  56. });
  57. </script>
  58. </head>

  59. <body>
  60. </body>
  61. </html>
复制代码

评分

参与人数 1经验值 +18 生活币 +18 贡献值 +1 收起 理由
joe + 18 + 18 + 1 很给力!

查看全部评分

 楼主| Jethro 发表于 2011-6-4 15:30 | 显示全部楼层
本帖最后由 Jethro 于 2011-6-4 15:47 编辑

ExtJS4学习笔记(二)---HBox的使用
要使用HBox布局方式,首先的熟悉下一下几个主要属性:

一、align:字符类型,指示组件在容器内的对齐方式。有如下几种属性。

    1、top(默认):排列于容器顶端。

    2、middle:垂直居中排列于容器中。

    3、stretch:垂直排列且拉伸义填补容器高度

    4、stretchmax:垂直拉伸,并且组件以最高高度的组件为准。

二、flex:数字类型,指示组件在容器中水平呈现方式,通俗的讲,就是指示组件在容器中的相对宽度。

三、pack : 字符类型,指示组件在容器的位置,有如下几种属性。

    1、start(默认):组件在容器左边

    2、center:组件在容器中间

    3、end:组件在容器的右边

实例代码:

一、HTML代码:
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  5. <title>HBox实例--www.51myit.com</title>
  6. <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
  7. <script type="text/javascript" src="../../bootstrap.js"></script>
  8. <script type="text/javascript" src="../../locale/ext-lang-zh_CN.js"></script>
  9. <script type="text/javascript" src="hbox.js"></script>

  10. </head>

  11. <body>


  12. </body>
  13. <div id="d1"></div>
  14. <div id="d2"></div>
  15. <div id="d3"></div>
  16. </html>
复制代码
hbox.js代码:
  1. Ext.onReady(function(){
  2.    var d1 = Ext.create('Ext.Panel',{
  3.   title:'HBox 顶对齐,且组件在容器的左边',
  4.   frame:true,
  5.   width:600,
  6.   height:100,
  7.   items:[{
  8.     anchor:'100%',
  9.     layout: {
  10.         type:'hbox',
  11.         padding:'10',
  12.         pack:'start',
  13.         align:'top'
  14.     },
  15.     defaults:{margins:'0 5 0 0'},
  16.     items:[{
  17.         xtype:'button',
  18.         text: 'Button 1'
  19.     },{
  20.         xtype:'button',
  21.         text: 'Button 2'
  22.     },{
  23.         xtype:'button',
  24.         text: 'Button 3'
  25.     },{
  26.         xtype:'button',
  27.         text: 'Button 4'
  28.     }]
  29.   }]
  30. })
  31.    
  32. d1.render('d1');


  33. var d2 = Ext.create('Ext.Panel',{
  34.   title:'HBox 垂直对齐,且组件在容器的右边',
  35.   frame:true,
  36.   width:600,
  37.   height:100,
  38.   items:[{
  39.     anchor:'100%',
  40.     layout: {
  41.         type:'hbox',
  42.         padding:'10',
  43.         align:'middle',
  44.         pack:'end'
  45.     },
  46.     defaults:{margins:'0 5 0 0'},
  47.     items:[{
  48.         xtype:'button',
  49.         text: 'Button 1'
  50.     },{
  51.         xtype:'button',
  52.         text: 'Button 2'
  53.     },{
  54.         xtype:'button',
  55.         text: 'Button 3'
  56.     },{
  57.         xtype:'button',
  58.         text: 'Button 4'
  59.     }]
  60.   }]
  61. })
  62.    
  63. d2.render('d2');

  64. var d3 = Ext.create('Ext.Panel',{
  65.   title:'HBox 垂直水平居中,并且所有控件高度为最高控件的高度',
  66.   frame:true,
  67.   width:600,
  68.   height:100,
  69.   items:[{
  70.      anchor:'100%',
  71.          
  72.      layout: {
  73.         type: 'hbox',
  74.         padding:'5',
  75.         align:'stretchmax',
  76.         pack:'center'
  77.     },
  78.     defaults:{margins:'0 5 0 0'},
  79.     items:[{
  80.         xtype:'button',
  81.         text: 'Small Size'
  82.     },{
  83.         xtype:'button',
  84.         scale: 'medium',
  85.         text: 'Medium Size'
  86.     },{
  87.         xtype:'button',
  88.         scale: 'large',
  89.         text: 'Large Size'
  90.     }]
  91.   }]
  92. })
  93.    
  94. d3.render('d3');



  95. })
  96. Ext.onReady(function(){
  97.     var d1 = Ext.create('Ext.Panel',{
  98.           title:'HBox 顶对齐,且组件在容器的左边',
  99.           frame:true,
  100.           width:600,
  101.           height:100,
  102.           items:[{
  103.             anchor:'100%',
  104.                 layout: {
  105.                         type:'hbox',
  106.                         padding:'10',
  107.                         pack:'start',
  108.                         align:'top'
  109.                 },
  110.                 defaults:{margins:'0 5 0 0'},
  111.                 items:[{
  112.                         xtype:'button',
  113.                         text: 'Button 1'
  114.                 },{
  115.                         xtype:'button',
  116.                         text: 'Button 2'
  117.                 },{
  118.                         xtype:'button',
  119.                         text: 'Button 3'
  120.                 },{
  121.                         xtype:'button',
  122.                         text: 'Button 4'
  123.                 }]
  124.           }]
  125.         })
  126.    
  127.         d1.render('d1');
  128.        
  129.        
  130.         var d2 = Ext.create('Ext.Panel',{
  131.           title:'HBox 垂直对齐,且组件在容器的右边',
  132.           frame:true,
  133.           width:600,
  134.           height:100,
  135.           items:[{
  136.             anchor:'100%',
  137.                 layout: {
  138.                         type:'hbox',
  139.                         padding:'10',
  140.                         align:'middle',
  141.                         pack:'end'
  142.                 },
  143.                 defaults:{margins:'0 5 0 0'},
  144.                 items:[{
  145.                         xtype:'button',
  146.                         text: 'Button 1'
  147.                 },{
  148.                         xtype:'button',
  149.                         text: 'Button 2'
  150.                 },{
  151.                         xtype:'button',
  152.                         text: 'Button 3'
  153.                 },{
  154.                         xtype:'button',
  155.                         text: 'Button 4'
  156.                 }]
  157.           }]
  158.         })
  159.    
  160.         d2.render('d2');
  161.        
  162.         var d3 = Ext.create('Ext.Panel',{
  163.           title:'HBox 垂直水平居中,并且所有控件高度为最高控件的高度',
  164.           frame:true,
  165.           width:600,
  166.           height:100,
  167.           items:[{
  168.              anchor:'100%',
  169.          
  170.                  layout: {
  171.                         type: 'hbox',
  172.                         padding:'5',
  173.                         align:'stretchmax',
  174.                         pack:'center'
  175.                 },
  176.                 defaults:{margins:'0 5 0 0'},
  177.                 items:[{
  178.                         xtype:'button',
  179.                         text: 'Small Size'
  180.                 },{
  181.                         xtype:'button',
  182.                         scale: 'medium',
  183.                         text: 'Medium Size'
  184.                 },{
  185.                         xtype:'button',
  186.                         scale: 'large',
  187.                         text: 'Large Size'
  188.                 }]
  189.           }]
  190.         })
  191.    
  192.         d3.render('d3');
  193.        
  194.        
  195.        
  196.   })
复制代码
最后是效果图:

5113745354.png

另外多种的布局方式,大家自己尝试就OK了。

 楼主| Jethro 发表于 2011-6-4 15:35 | 显示全部楼层
本帖最后由 Jethro 于 2011-6-4 15:46 编辑

ExtJS4学习笔记(三)---VBox的使用

要使用VBox布局方式,首先的熟悉下一下几个主要属性:

一、align:字符类型,指示组件在容器内的对齐方式。有如下几种属性。

    1、left(默认):排列于容器左侧。

    2、center :控件在容器水平居中。

    3、stretch:控件横向拉伸至容器大小

    4、stretchmax:控件横向拉伸,宽度为最宽控件的宽。

二、flex:数字类型,指示组件在容器中水平呈现方式,通俗的讲,就是指示组件在容器中的相对宽度。

三、pack : 字符类型,指示组件在容器的位置,有如下几种属性。

    1、start(默认):组件在容器上边

    2、center:组件在容器中间

    3、end:组件在容器的下边



HTML代码:
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  5. <title>VBox---www.51myit.com</title>
  6. <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
  7. <script type="text/javascript" src="../../bootstrap.js"></script>
  8. <script type="text/javascript" src="../../locale/ext-lang-zh_CN.js"></script>
  9. <script type="text/javascript" src="vbox.js"></script>
  10. <style type="text/css">
  11.         html, body {
  12.             font: normal 12px verdana;
  13.             margin: 0;
  14.             padding: 0;
  15.             border: 0 none;
  16.         }
  17.     </style>
  18. </head>

  19. <body>
  20. </body>
  21. </html>
复制代码
vbox.js:代码太大,论坛限制发贴字数,请下载附件包。
vbox.rar (1.89 KB, 下载次数: 16)

 楼主| Jethro 发表于 2011-6-4 15:37 | 显示全部楼层
本帖最后由 Jethro 于 2011-6-4 15:46 编辑

ExtJS4学习笔记(四)---Grid的使用

Extjs4 Grid创建还是比较容易的,难记、难理解的地方,也就是数据的获取。下面,就创建一个最简单的Grid组件,后面,我们会逐渐丰富这个Grid的功能。

HTML代码:
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Grid-www.51myit.com</title>
  6. <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
  7.     <script type="text/javascript" src="../../bootstrap.js"></script>
  8.     <script type="text/javascript" src="../../locale/ext-lang-zh_CN.js"></script>
  9.     <script type="text/javascript" src="grid.js"></script>
  10. </head>

  11. <body>
  12. <div id="demo"></div>
  13. </body>
  14. </html>
复制代码
grid.js:
  1. Ext.require([
  2.     'Ext.grid.*',
  3.     'Ext.data.*'
  4. ]);
  5. Ext.onReady(function(){
  6.     Ext.define('MyData',{
  7.         extend: 'Ext.data.Model',
  8.         fields: [
  9.             //第一个字段需要指定mapping,其他字段,可以省略掉。
  10.             {name:'UserName',mapping:'UserName'},
  11.              'Sex',
  12.              'Age',
  13.              'XueHao',
  14.              'BanJi'
  15.         ]
  16.     });
  17.      
  18.     //创建数据源
  19.     var store = Ext.create('Ext.data.Store', {
  20.         model: 'MyData',
  21.         proxy: {
  22.            //异步获取数据,这里的URL可以改为任何动态页面,只要返回JSON数据即可
  23.             type: 'ajax',
  24.             url: 'mydata.json',
  25.             
  26.             reader: {
  27.                 type: 'json',
  28.                 root: 'items',
  29.                 //totalProperty  : 'total'
  30.             }
  31.         },
  32.         autoLoad: true
  33.     });
  34.      
  35.     //创建Grid
  36.     var grid = Ext.create('Ext.grid.Panel',{
  37.         store: store,
  38.         columns: [
  39.             {text: "姓名", width: 120, dataIndex: 'UserName', sortable: true},
  40.             {text: "性别", flex: 1, dataIndex: 'Sex', sortable: false},
  41.             {text: "年龄", width: 100, dataIndex: 'Age', sortable: true},
  42.             {text: "学号", width: 100, dataIndex: 'XueHao', sortable: true},
  43.             {text: "班级", width: 100, dataIndex: 'BanJi', sortable: true}
  44.         ],
  45.         height:400,
  46.         width:480,
  47.         x:20,
  48.         y:40,
  49.         title: 'ExtJS4 Grid示例',
  50.         renderTo: 'demo',
  51.         viewConfig: {
  52.             stripeRows: true
  53.         }
  54.     })
  55. })
  56. Ext.require([
  57.     'Ext.grid.*',
  58.     'Ext.data.*'
  59. ]);
  60. Ext.onReady(function(){
  61.     Ext.define('MyData',{
  62.             extend: 'Ext.data.Model',
  63.                 fields: [
  64.                     //第一个字段需要指定mapping,其他字段,可以省略掉。
  65.                     {name:'UserName',mapping:'UserName'},
  66.                          'Sex',
  67.                          'Age',
  68.                          'XueHao',
  69.                          'BanJi'
  70.                 ]
  71.         });
  72.        
  73.         //创建数据源
  74.         var store = Ext.create('Ext.data.Store', {
  75.         model: 'MyData',
  76.         proxy: {
  77.            //异步获取数据,这里的URL可以改为任何动态页面,只要返回JSON数据即可
  78.             type: 'ajax',
  79.             url: 'mydata.json',
  80.             
  81.             reader: {
  82.                 type: 'json',
  83.                 root: 'items',
  84.                 //totalProperty  : 'total'
  85.             }
  86.         },
  87.                 autoLoad: true
  88.     });
  89.        
  90.         //创建Grid
  91.         var grid = Ext.create('Ext.grid.Panel',{
  92.             store: store,
  93.                 columns: [
  94.             {text: "姓名", width: 120, dataIndex: 'UserName', sortable: true},
  95.             {text: "性别", flex: 1, dataIndex: 'Sex', sortable: false},
  96.             {text: "年龄", width: 100, dataIndex: 'Age', sortable: true},
  97.             {text: "学号", width: 100, dataIndex: 'XueHao', sortable: true},
  98.             {text: "班级", width: 100, dataIndex: 'BanJi', sortable: true}
  99.         ],
  100.                 height:400,
  101.                 width:480,
  102.                 x:20,
  103.                 y:40,
  104.                 title: 'ExtJS4 Grid示例',
  105.         renderTo: 'demo',
  106.         viewConfig: {
  107.             stripeRows: true
  108.         }
  109.         })
  110. })
复制代码
mydata.json:当然,你也可以使用任意服务端程序返回json数据(asp?.net?java还是php,看你的爱好了)

  1. {  
  2.     "items": [  
  3.         {  
  4.             "UserName": "李彦宏",  
  5.             "Sex": "男",  
  6.             "Age":25,
  7.             "XueHao":00001,
  8.             "BanJi":"一班"
  9.         },  
  10.         {  
  11.             "UserName": "马云",  
  12.             "Sex": "男",  
  13.             "Age":31,
  14.             "XueHao":00002,
  15.             "BanJi":"二班"
  16.         },
  17.         {  
  18.             "UserName": "张朝阳",  
  19.             "Sex": "男",  
  20.             "Age":30,
  21.             "XueHao":00003,
  22.             "BanJi":"一班"
  23.         },
  24.         {  
  25.             "UserName": "朱俊",  
  26.             "Sex": "男",  
  27.             "Age":28,
  28.             "XueHao":00004,
  29.             "BanJi":"一班"
  30.         },
  31.         {  
  32.             "UserName": "丁磊",  
  33.             "Sex": "男",  
  34.             "Age":29,
  35.             "XueHao":00005,
  36.             "BanJi":"二班"
  37.         },
  38.         {  
  39.             "UserName": "李国军",  
  40.             "Sex": "男",  
  41.             "Age":30,
  42.             "XueHao":00006,
  43.             "BanJi":"二班"
  44.         },
  45.         {  
  46.             "UserName": "王志宝",  
  47.             "Sex": "男",  
  48.             "Age":25,
  49.             "XueHao":00007,
  50.             "BanJi":"一班"
  51.         }
  52.     ]  
  53. }  
  54. {
  55.     "items": [
  56.         {
  57.             "UserName": "李彦宏",
  58.             "Sex": "男",
  59.             "Age":25,
  60.                         "XueHao":00001,
  61.                         "BanJi":"一班"
  62.         },
  63.                 {
  64.             "UserName": "马云",
  65.             "Sex": "男",
  66.             "Age":31,
  67.                         "XueHao":00002,
  68.                         "BanJi":"二班"
  69.         },
  70.                 {
  71.             "UserName": "张朝阳",
  72.             "Sex": "男",
  73.             "Age":30,
  74.                         "XueHao":00003,
  75.                         "BanJi":"一班"
  76.         },
  77.                 {
  78.             "UserName": "朱俊",
  79.             "Sex": "男",
  80.             "Age":28,
  81.                         "XueHao":00004,
  82.                         "BanJi":"一班"
  83.         },
  84.                 {
  85.             "UserName": "丁磊",
  86.             "Sex": "男",
  87.             "Age":29,
  88.                         "XueHao":00005,
  89.                         "BanJi":"二班"
  90.         },
  91.                 {
  92.             "UserName": "李国军",
  93.             "Sex": "男",
  94.             "Age":30,
  95.                         "XueHao":00006,
  96.                         "BanJi":"二班"
  97.         },
  98.                 {
  99.             "UserName": "王志宝",
  100.             "Sex": "男",
  101.             "Age":25,
  102.                         "XueHao":00007,
  103.                         "BanJi":"一班"
  104.         }
  105.     ]
  106. }
复制代码
Extjs4 Grid组件的数据需要几点注意。

第一,就是数据类型,我们可以指定数据类型,比如:
  1. var store = Ext.create('Ext.data.ArrayStore', {
  2.         fields: [
  3.            {name: 'company'},
  4.            {name: 'price',      type: 'float'},
  5.            {name: 'change',     type: 'float'},
  6.            {name: 'pctChange',  type: 'float'},
  7.            {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}
  8.         ],
  9.         data: myData
  10.     });
  11. var store = Ext.create('Ext.data.ArrayStore', {
  12.         fields: [
  13.            {name: 'company'},
  14.            {name: 'price',      type: 'float'},
  15.            {name: 'change',     type: 'float'},
  16.            {name: 'pctChange',  type: 'float'},
  17.            {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}
  18.         ],
  19.         data: myData
  20.     });
复制代码
数据类型分为以下几种:

1、auto(默认)
2、string
3、int
4、float
5、boolean
6、date

第二:Ext.data.Model,示例中,只指定了一个mapping,那么第一个mapping是必须要指定的,从第二个开始,我们就不需要再去指定mapping了,Extjs很聪明,他会根据数据来判断需要的mapping。

 楼主| Jethro 发表于 2011-6-4 15:39 | 显示全部楼层
本帖最后由 Jethro 于 2011-6-4 15:45 编辑

ExtJS4学习笔记(五)---Grid分页

Grid组件,当数据量很大的时候,就需要分页显示,本文介绍如何实现Extjs4 Grid的分页功能。

先看THML代码:
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Paging Grid-www.51myit.com</title>
  6. <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
  7. <script type="text/javascript" src="../../bootstrap.js"></script>
  8. <script type="text/javascript" src="../../locale/ext-lang-zh_CN.js"></script>
  9. <script type="text/javascript" src="paing.js"></script>
  10. </head>

  11. <body>
  12. <div id="demo"></div>
  13. </body>
  14. </html>
复制代码
这里引用的JS文件,都是相对于Extjs4整个目录的。如果已经将JS和CSS文件剥离并分目录放置了,那么一定要注意修改bootstrap.js。

JS代码:
  1. Ext.require([
  2.     'Ext.grid.*',
  3.     'Ext.toolbar.Paging',
  4.     'Ext.data.*'
  5. ]);

  6. Ext.onReady(function(){
  7.     Ext.define('MyData',{
  8.         extend: 'Ext.data.Model',
  9.         fields: [
  10.             'title','author',
  11.             //第一个字段需要指定mapping,其他字段,可以省略掉。
  12.             {name:'hits',type: 'int'},
  13.              'addtime'
  14.         ]
  15.     });
  16.      
  17.     //创建数据源
  18.     var store = Ext.create('Ext.data.Store', {
  19.         //分页大小
  20.         pageSize: 50,
  21.         model: 'MyData',
  22.         //是否在服务端排序
  23.         remoteSort: true,
  24.         proxy: {
  25.            //异步获取数据,这里的URL可以改为任何动态页面,只要返回JSON数据即可
  26.             type: 'ajax',
  27.             url: 'mydata.asp',
  28.             
  29.             reader: {
  30.                 root: 'items',
  31.                 totalProperty  : 'total'
  32.             },
  33.             simpleSortMode: true
  34.         },
  35.         sorters: [{
  36.             //排序字段。
  37.             property: 'hits',
  38.             //排序类型,默认为 ASC
  39.             direction: 'DESC'
  40.         }]
  41.     });
  42.      
  43.     //创建Grid
  44.     var grid = Ext.create('Ext.grid.Panel',{
  45.         store: store,
  46.         columns: [
  47.             {text: "标题", width: 120, dataIndex: 'title', sortable: true},
  48.             {text: "作者", flex: 200, dataIndex: 'author', sortable: false},
  49.             {text: "点击数", width: 100, dataIndex: 'hits', sortable: true},
  50.             {text: "添加时间", width: 100, dataIndex: 'addtime', sortable: true}
  51.         ],
  52.         height:400,
  53.         width:520,
  54.         x:20,
  55.         y:40,
  56.         title: 'ExtJS4 Grid 分页示例',
  57.         disableSelection: true,
  58.         loadMask: true,
  59.         renderTo: 'demo',
  60.         viewConfig: {
  61.             id: 'gv',
  62.             trackOver: false,
  63.             stripeRows: false
  64.         },
  65.          
  66.         bbar: Ext.create('Ext.PagingToolbar', {
  67.             store: store,
  68.             displayInfo: true,
  69.             displayMsg: '显示 {0} - {1} 条,共计 {2} 条',
  70.             emptyMsg: "没有数据"
  71.         })
  72.     })
  73.     store.loadPage(1);
  74. })
  75. Ext.require([
  76.     'Ext.grid.*',
  77.         'Ext.toolbar.Paging',
  78.     'Ext.data.*'
  79. ]);

  80. Ext.onReady(function(){
  81.     Ext.define('MyData',{
  82.             extend: 'Ext.data.Model',
  83.                 fields: [
  84.                         'title','author',
  85.                     //第一个字段需要指定mapping,其他字段,可以省略掉。
  86.                     {name:'hits',type: 'int'},
  87.                          'addtime'
  88.                 ]
  89.         });
  90.        
  91.         //创建数据源
  92.         var store = Ext.create('Ext.data.Store', {
  93.                 //分页大小
  94.                 pageSize: 50,
  95.         model: 'MyData',
  96.                 //是否在服务端排序
  97.                 remoteSort: true,
  98.         proxy: {
  99.            //异步获取数据,这里的URL可以改为任何动态页面,只要返回JSON数据即可
  100.             type: 'ajax',
  101.             url: 'mydata.asp',
  102.             
  103.             reader: {
  104.                 root: 'items',
  105.                 totalProperty  : 'total'
  106.             },
  107.                         simpleSortMode: true
  108.         },
  109.         sorters: [{
  110.                         //排序字段。
  111.             property: 'hits',
  112.                         //排序类型,默认为 ASC
  113.             direction: 'DESC'
  114.         }]
  115.     });
  116.        
  117.         //创建Grid
  118.         var grid = Ext.create('Ext.grid.Panel',{
  119.             store: store,
  120.                 columns: [
  121.             {text: "标题", width: 120, dataIndex: 'title', sortable: true},
  122.             {text: "作者", flex: 200, dataIndex: 'author', sortable: false},
  123.             {text: "点击数", width: 100, dataIndex: 'hits', sortable: true},
  124.             {text: "添加时间", width: 100, dataIndex: 'addtime', sortable: true}
  125.         ],
  126.                 height:400,
  127.                 width:520,
  128.                 x:20,
  129.                 y:40,
  130.                 title: 'ExtJS4 Grid 分页示例',
  131.                 disableSelection: true,
  132.         loadMask: true,
  133.         renderTo: 'demo',
  134.         viewConfig: {
  135.                         id: 'gv',
  136.                         trackOver: false,
  137.             stripeRows: false
  138.         },
  139.                
  140.         bbar: Ext.create('Ext.PagingToolbar', {
  141.             store: store,
  142.             displayInfo: true,
  143.             displayMsg: '显示 {0} - {1} 条,共计 {2} 条',
  144.             emptyMsg: "没有数据"
  145.         })
  146.         })
  147.         store.loadPage(1);
  148. })
复制代码
关于数据,任何服务端都可以,只要返回相应的数据就可以了。这里简单使用ASP代码做了一些测试用的数据,但是这些测试代码包含了参数接收、基本判断以及分页方法。具体情况具体实施,这些代码只作为抛砖引玉的作用。

ASP代码:
  1. <%
  2.     Response.ContentType = "text/html"
  3.     Response.Charset = "UTF-8"
  4. %>
  5. <%
  6. '返回JSON数据,自定义一些测试数据。。
  7. '这里的参数与EXT3.x相同,区别在于排序字段和排序方式使用了新的属性。
  8. '由于这里是测试数据,接收的参数只用到了start,limit。sorts和dir在实际操作过程中,将之加入SQL的ORDER BY里即可。
  9. start = Request("start")
  10. limit = Request("limit")
  11. If start = "" Then
  12.     start = 0
  13. End If
  14. If limit = "" Then
  15.     limit = 50
  16. End If
  17. sorts = Replace(Trim(Request.Form("sort")),"'","")  
  18. dir = Replace(Trim(Request.Form("dir")),"'","")

  19. Dim counts:counts=300
  20. '注意,这里的counts相当于Rs.RecordCount,也就是记录总数。

  21. Dim Ls:Ls = Cint(start) + Cint(limit)
  22. If Ls >= counts Then
  23.    Ls = counts
  24. End If

  25. Echo("{")
  26. Echo("""total"":")
  27. Echo(""""&counts&""",")
  28. Echo("""items"":[")
  29. For i = start+1 To Ls
  30.    Echo("{")
  31.    Echo("""title"":""newstitle"&i&"""")
  32.    Echo(",")
  33.    Echo("""author"":""author"&i&"""")
  34.    Echo(",")
  35.    Echo("""hits"":"""&i&"""")
  36.    Echo(",")
  37.    Echo("""addtime"":"""&Now()&"""")
  38.    Echo("}")
  39.    If i<Ls Then
  40.      Echo(",")
  41.    End If
  42. Next
  43. Echo("]}")
  44. Function Echo(str)
  45.    Response.Write(str)
  46. End Function
  47. %>
  48. <%
  49.         Response.ContentType = "text/html"
  50.         Response.Charset = "UTF-8"
  51. %>
  52. <%
  53. '返回JSON数据,自定义一些测试数据。。
  54. '这里的参数与EXT3.x相同,区别在于排序字段和排序方式使用了新的属性。
  55. '由于这里是测试数据,接收的参数只用到了start,limit。sorts和dir在实际操作过程中,将之加入SQL的ORDER BY里即可。
  56. start = Request("start")
  57. limit = Request("limit")
  58. If start = "" Then
  59.         start = 0
  60. End If
  61. If limit = "" Then
  62.         limit = 50
  63. End If
  64. sorts = Replace(Trim(Request.Form("sort")),"'","")
  65. dir = Replace(Trim(Request.Form("dir")),"'","")

  66. Dim counts:counts=300
  67. '注意,这里的counts相当于Rs.RecordCount,也就是记录总数。

  68. Dim Ls:Ls = Cint(start) + Cint(limit)
  69. If Ls >= counts Then
  70.    Ls = counts
  71. End If

  72. Echo("{")
  73. Echo("""total"":")
  74. Echo(""""&counts&""",")
  75. Echo("""items"":[")
  76. For i = start+1 To Ls
  77.    Echo("{")
  78.    Echo("""title"":""newstitle"&i&"""")
  79.    Echo(",")
  80.    Echo("""author"":""author"&i&"""")
  81.    Echo(",")
  82.    Echo("""hits"":"""&i&"""")
  83.    Echo(",")
  84.    Echo("""addtime"":"""&Now()&"""")
  85.    Echo("}")
  86.    If i<Ls Then
  87.      Echo(",")
  88.    End If
  89. Next
  90. Echo("]}")
  91. Function Echo(str)
  92.    Response.Write(str)
  93. End Function
  94. %>
复制代码
最后,来张效果图:

1812354901.png
 楼主| Jethro 发表于 2011-6-4 15:43 | 显示全部楼层
本帖最后由 Jethro 于 2011-6-4 15:45 编辑

ExtJS4学习笔记(六)---多表头Grid
做项目的时候,有时候会遇到多表头的Grid,在EXTJS4中,多表头的实现已经很简单了,本文介绍如何实现多表头gird的功能。

上一笔记讲的是如何实现Grid的分页功能,本文在此基础上做出修改,达到多表头Grid+分页功能。

先看下效果图:
19113236197.jpg


实现代码如下:

HTML代码:
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>GroupHeaderGrid-www.51myit.com</title>
  6. <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
  7. <script type="text/javascript" src="../../bootstrap.js"></script>
  8. <script type="text/javascript" src="../../locale/ext-lang-zh_CN.js"></script>
  9. <script type="text/javascript" src="group-header.js"></script>
  10. </head>

  11. <body>
  12. <div id="demo"></div>
  13. </body>
  14. </html>
复制代码
group-header.js:
  1. Ext.require([
  2.     'Ext.grid.*',
  3.     'Ext.toolbar.Paging',
  4.     'Ext.util.*',
  5.     'Ext.data.*'
  6. ]);

  7. Ext.onReady(function(){
  8.     Ext.define('MyData',{
  9.         extend: 'Ext.data.Model',
  10.         fields: [
  11.             'title','author',
  12.             //第一个字段需要指定mapping,其他字段,可以省略掉。
  13.             {name:'hits',type: 'int'},
  14.              'addtime'
  15.         ]
  16.     });
  17.      
  18.     //创建数据源
  19.     var store = Ext.create('Ext.data.Store', {
  20.         //分页大小
  21.         pageSize: 50,
  22.         model: 'MyData',
  23.         //是否在服务端排序
  24.         remoteSort: true,
  25.         proxy: {
  26.            //异步获取数据,这里的URL可以改为任何动态页面,只要返回JSON数据即可
  27.             type: 'ajax',
  28.             url: 'mydata.asp',
  29.             
  30.             reader: {
  31.                 root: 'items',
  32.                 totalProperty  : 'total'
  33.             },
  34.             simpleSortMode: true
  35.         },
  36.         sorters: [{
  37.             //排序字段。
  38.             property: 'hits',
  39.             //排序类型,默认为 ASC
  40.             direction: 'DESC'
  41.         }]
  42.     });
  43.      
  44.     //创建Grid
  45.     var grid = Ext.create('Ext.grid.Panel',{
  46.         store: store,
  47.         columnLines: true,
  48.         columns: [{
  49.             text:"基本信息",
  50.             columns:[
  51.                 {text: "标题", width: 120, dataIndex: 'title', sortable: true},
  52.                 {text: "作者", width: 200, dataIndex: 'author', sortable: false},
  53.                 {text: "点击数", width: 100, dataIndex: 'hits', sortable: true}]
  54.             },
  55.             {text: "添加时间", width: 100, dataIndex: 'addtime', sortable: true}
  56.         ],
  57.         height:400,
  58.         width:520,
  59.         x:20,
  60.         y:40,
  61.         title: 'ExtJS4 多表头Grid带分页示例',
  62.         disableSelection: true,
  63.         loadMask: true,
  64.         renderTo: 'demo',
  65.         viewConfig: {
  66.             id: 'gv',
  67.             trackOver: false,
  68.             stripeRows: false
  69.         },
  70.          
  71.         bbar: Ext.create('Ext.PagingToolbar', {
  72.             store: store,
  73.             displayInfo: true,
  74.             displayMsg: '显示 {0} - {1} 条,共计 {2} 条',
  75.             emptyMsg: "没有数据"
  76.         })
  77.     })
  78.     store.loadPage(1);
  79. })
  80. Ext.require([
  81.     'Ext.grid.*',
  82.         'Ext.toolbar.Paging',
  83.         'Ext.util.*',
  84.     'Ext.data.*'
  85. ]);

  86. Ext.onReady(function(){
  87.     Ext.define('MyData',{
  88.             extend: 'Ext.data.Model',
  89.                 fields: [
  90.                         'title','author',
  91.                     //第一个字段需要指定mapping,其他字段,可以省略掉。
  92.                     {name:'hits',type: 'int'},
  93.                          'addtime'
  94.                 ]
  95.         });
  96.        
  97.         //创建数据源
  98.         var store = Ext.create('Ext.data.Store', {
  99.                 //分页大小
  100.                 pageSize: 50,
  101.         model: 'MyData',
  102.                 //是否在服务端排序
  103.                 remoteSort: true,
  104.         proxy: {
  105.            //异步获取数据,这里的URL可以改为任何动态页面,只要返回JSON数据即可
  106.             type: 'ajax',
  107.             url: 'mydata.asp',
  108.             
  109.             reader: {
  110.                 root: 'items',
  111.                 totalProperty  : 'total'
  112.             },
  113.                         simpleSortMode: true
  114.         },
  115.         sorters: [{
  116.                         //排序字段。
  117.             property: 'hits',
  118.                         //排序类型,默认为 ASC
  119.             direction: 'DESC'
  120.         }]
  121.     });
  122.        
  123.         //创建Grid
  124.         var grid = Ext.create('Ext.grid.Panel',{
  125.             store: store,
  126.                 columnLines: true,
  127.                 columns: [{
  128.                         text:"基本信息",
  129.                         columns:[
  130.                             {text: "标题", width: 120, dataIndex: 'title', sortable: true},
  131.                 {text: "作者", width: 200, dataIndex: 'author', sortable: false},
  132.                 {text: "点击数", width: 100, dataIndex: 'hits', sortable: true}]
  133.                         },
  134.             {text: "添加时间", width: 100, dataIndex: 'addtime', sortable: true}
  135.         ],
  136.                 height:400,
  137.                 width:520,
  138.                 x:20,
  139.                 y:40,
  140.                 title: 'ExtJS4 多表头Grid带分页示例',
  141.                 disableSelection: true,
  142.         loadMask: true,
  143.         renderTo: 'demo',
  144.         viewConfig: {
  145.                         id: 'gv',
  146.                         trackOver: false,
  147.             stripeRows: false
  148.         },
  149.                
  150.         bbar: Ext.create('Ext.PagingToolbar', {
  151.             store: store,
  152.             displayInfo: true,
  153.             displayMsg: '显示 {0} - {1} 条,共计 {2} 条',
  154.             emptyMsg: "没有数据"
  155.         })
  156.         })
  157.         store.loadPage(1);
  158. })
复制代码
JS代码要注意的地方:

1、记得载入'Ext.util.*',

2、二级表头必须指定宽度,如果不指定的话,会提示错误。如图所示,红框里的项,必须要指定宽度。

服务端代码,这里使用ASP编写,具体解释请参考前一篇文章。
  1. <%
  2.     Response.ContentType = "text/html"
  3.     Response.Charset = "UTF-8"
  4. %>
  5. <%
  6. '返回JSON数据,自定义一些测试数据。。
  7. '这里的参数与EXT3.x相同,区别在于排序字段和排序方式使用了新的属性。
  8. '由于这里是测试数据,接收的参数只用到了start,limit。sorts和dir在实际操作过程中,将之加入SQL的ORDER BY里即可。
  9. start = Request("start")
  10. limit = Request("limit")
  11. If start = "" Then
  12.     start = 0
  13. End If
  14. If limit = "" Then
  15.     limit = 50
  16. End If
  17. sorts = Replace(Trim(Request.Form("sort")),"'","")  
  18. dir = Replace(Trim(Request.Form("dir")),"'","")

  19. Dim counts:counts=300
  20. '注意,这里的counts相当于Rs.RecordCount,也就是记录总数。

  21. Dim Ls:Ls = Cint(start) + Cint(limit)
  22. If Ls >= counts Then
  23.    Ls = counts
  24. End If

  25. Echo("{")
  26. Echo("""total"":")
  27. Echo(""""&counts&""",")
  28. Echo("""items"":[")
  29. For i = start+1 To Ls
  30.    Echo("{")
  31.    Echo("""title"":""newstitle"&i&"""")
  32.    Echo(",")
  33.    Echo("""author"":""author"&i&"""")
  34.    Echo(",")
  35.    Echo("""hits"":"""&i&"""")
  36.    Echo(",")
  37.    Echo("""addtime"":"""&Now()&"""")
  38.    Echo("}")
  39.    If i<Ls Then
  40.      Echo(",")
  41.    End If
  42. Next
  43. Echo("]}")
  44. Function Echo(str)
  45.    Response.Write(str)
  46. End Function
  47. %>
复制代码
 楼主| Jethro 发表于 2011-6-4 15:53 | 显示全部楼层
ExtJS4学习笔记(七)---带搜索的Grid(SearchGrid)
发布时间:2011-05-21    来源:mhzg    作者:佚名    点击:
项目开发中,Grid组件少不了搜索功能,在Extjs4中,搜索组件以插件的形式出现,而且实现也非常简单,搜索组件位于examples/ux/form目录下,JS文件是SearchField.js。

Grid加载搜索功能,要注意的是:

1、开启延迟加载,即Ext.Loader.setConfig({enabled: true});

2、设置插件的目录:Ext.Loader.setPath('Ext.ux', '../../examples/ux'); ,需要注意,插件所在目录一定要正确,否则加载失败,就实现不了所要功能了。

效果图:
222.jpg
初始加载

111.jpg

输入查询条件后



HTML代码:
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>SearchGrid-www.51myit.com</title>
  6. <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
  7. <style type="text/css">
  8.         #search-results a {
  9.             color: #385F95;
  10.             font:bold 11px tahoma, arial, helvetica, sans-serif;
  11.             text-decoration:none;
  12.         }
  13.          
  14.         #search-results a:hover {
  15.             text-decoration:underline;
  16.         }
  17.          
  18.         #search-results p {
  19.             margin:3px !important;
  20.         }
  21.          
  22.         .search-item {
  23.             font:normal 11px tahoma, arial, helvetica, sans-serif;
  24.             padding:3px 10px 3px 10px;
  25.             border:1px solid #fff;
  26.             border-bottom:1px solid #eeeeee;
  27.             white-space:normal;
  28.             color:#555;
  29.         }
  30.         .search-item h3 {
  31.             display:block;
  32.             font:inherit;
  33.             font-weight:bold;
  34.             color:#222;
  35.         }

  36.         .search-item h3 span {
  37.             float: right;
  38.             font-weight:normal;
  39.             margin:0 0 5px 5px;
  40.             width:100px;
  41.             display:block;
  42.             clear:none;
  43.         }
  44.         /*这里要注意这两张图片的路径要正确*/
  45.         .x-form-clear-trigger {
  46.             background-image: url(../../resources/themes/images/default/form/clear-trigger.gif);
  47.         }
  48.          
  49.         .x-form-search-trigger {
  50.             background-image: url(../../resources/themes/images/default/form/search-trigger.gif);
  51.         }
  52.     </style>
  53. <script type="text/javascript" src="../../bootstrap.js"></script>
  54. <script type="text/javascript" src="../../locale/ext-lang-zh_CN.js"></script>
  55. <script type="text/javascript" src="searchgrid.js"></script>
  56. </head>

  57. <body>
  58. <div id="demo"></div>
  59. </body>
  60. </html>
复制代码
SearchGrid.js:代码太长,请下载附件。
SearchGrid.rar (1.64 KB, 下载次数: 14)

代码完成了Grid组件异步加载信息、分页和搜索功能,可以满足一般使用情况了。

服务端代码,由于使用测试数据,这里只使用了最简单的方法来实现搜索效果,实际操作中,需要将查询条件置于SQL语句中,达到搜索效果。

SearchGrid.asp:
  1. <%
  2.     Response.ContentType = "text/html"
  3.     Response.Charset = "UTF-8"
  4. %>
  5. <%
  6. '返回JSON数据,自定义一些测试数据。。
  7. '这里的参数与EXT3.x相同,区别在于排序字段和排序方式使用了新的属性。
  8. '由于这里是测试数据,接收的参数只用到了start,limit。sorts和dir在实际操作过程中,将之加入SQL的ORDER BY里即可。
  9. start = Request("start")
  10. limit = Request("limit")
  11. '查询时获取的参数。
  12. query = Request("query")
  13. If start = "" Then
  14.     start = 0
  15. End If
  16. If limit = "" Then
  17.     limit = 50
  18. End If
  19. sorts = Replace(Trim(Request.Form("sort")),"'","")  
  20. dir = Replace(Trim(Request.Form("dir")),"'","")

  21. '测试数据,这里直接输出结果,实际应用中,应该把查询条件放到SQL语句中。
  22. If query = "newstitle" Then
  23.     Echo("{")
  24.     Echo("""total"":")
  25.     Echo("""1")
  26.     Echo(""",""items"":[")
  27.     Echo("{")
  28.     Echo("""title"":""newstitle""")
  29.     Echo(",")
  30.     Echo("""author"":""author""")
  31.     Echo(",")
  32.     Echo("""hits"":""100""")
  33.     Echo(",")
  34.     Echo("""addtime"":"""&Now()&"""")
  35.     Echo("}")
  36.     Echo("]}")
  37. Else
  38. Dim counts:counts=300
  39. '注意,这里的counts相当于Rs.RecordCount,也就是记录总数。

  40. Dim Ls:Ls = Cint(start) + Cint(limit)
  41. If Ls >= counts Then
  42.    Ls = counts
  43. End If

  44. Echo("{")
  45. Echo("""total"":")
  46. Echo(""""&counts&""",")
  47. Echo("""items"":[")
  48. For i = start+1 To Ls
  49.    Echo("{")
  50.    Echo("""title"":""newstitle"&i&"""")
  51.    Echo(",")
  52.    Echo("""author"":""author"&i&"""")
  53.    Echo(",")
  54.    Echo("""hits"":"""&i&"""")
  55.    Echo(",")
  56.    Echo("""addtime"":"""&Now()&"""")
  57.    Echo("}")
  58.    If i<Ls Then
  59.      Echo(",")
  60.    End If
  61. Next

  62. Echo("]}")
  63. End If
  64. Function Echo(str)
  65.    Response.Write(str)
  66. End Function
  67. %>
  68. <%
  69.         Response.ContentType = "text/html"
  70.         Response.Charset = "UTF-8"
  71. %>
  72. <%
  73. '返回JSON数据,自定义一些测试数据。。
  74. '这里的参数与EXT3.x相同,区别在于排序字段和排序方式使用了新的属性。
  75. '由于这里是测试数据,接收的参数只用到了start,limit。sorts和dir在实际操作过程中,将之加入SQL的ORDER BY里即可。
  76. start = Request("start")
  77. limit = Request("limit")
  78. '查询时获取的参数。
  79. query = Request("query")
  80. If start = "" Then
  81.         start = 0
  82. End If
  83. If limit = "" Then
  84.         limit = 50
  85. End If
  86. sorts = Replace(Trim(Request.Form("sort")),"'","")
  87. dir = Replace(Trim(Request.Form("dir")),"'","")

  88. '测试数据,这里直接输出结果,实际应用中,应该把查询条件放到SQL语句中。
  89. If query = "newstitle" Then
  90.     Echo("{")
  91.     Echo("""total"":")
  92.     Echo("""1")
  93.     Echo(""",""items"":[")
  94.     Echo("{")
  95.         Echo("""title"":""newstitle""")
  96.         Echo(",")
  97.         Echo("""author"":""author""")
  98.         Echo(",")
  99.         Echo("""hits"":""100""")
  100.     Echo(",")
  101.     Echo("""addtime"":"""&Now()&"""")
  102.     Echo("}")
  103.     Echo("]}")
  104. Else
  105. Dim counts:counts=300
  106. '注意,这里的counts相当于Rs.RecordCount,也就是记录总数。

  107. Dim Ls:Ls = Cint(start) + Cint(limit)
  108. If Ls >= counts Then
  109.    Ls = counts
  110. End If

  111. Echo("{")
  112. Echo("""total"":")
  113. Echo(""""&counts&""",")
  114. Echo("""items"":[")
  115. For i = start+1 To Ls
  116.    Echo("{")
  117.    Echo("""title"":""newstitle"&i&"""")
  118.    Echo(",")
  119.    Echo("""author"":""author"&i&"""")
  120.    Echo(",")
  121.    Echo("""hits"":"""&i&"""")
  122.    Echo(",")
  123.    Echo("""addtime"":"""&Now()&"""")
  124.    Echo("}")
  125.    If i<Ls Then
  126.      Echo(",")
  127.    End If
  128. Next

  129. Echo("]}")
  130. End If
  131. Function Echo(str)
  132.    Response.Write(str)
  133. End Function
  134. %>
复制代码
至此,带搜索功能的Grid就全部完成了。

Mark.Yao 发表于 2011-6-10 15:51 | 显示全部楼层
Ext.tree的分页请问有例子么.谢谢
岁月无声 发表于 2011-6-16 10:25 | 显示全部楼层
楼主厉害,希望以后有更多的4.0例子,我一定关注你的空间
reg2011 发表于 2011-6-17 20:48 | 显示全部楼层
<!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>窗口实例--www.51myit.com</title>
<link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
<script type="text/javascript" src="../../bootstrap.js"></script>
<script type="text/javascript" src="../../locale/ext-lang-zh_CN.js"></script>
<script type="text/jscript">
Ext.require('Ext.window');
Ext.onReady(function(){
  Ext.create('Ext.Window',{
    width:400,
    height:230,
    //X,Y标识窗口相对于父窗口的偏移值。
    x:10,
    y:10,
    plain: true,
    //指示标题头的位置,分别为 top,bottom,left,right,默认为top
    headerPosition: 'left',
    title: 'ExtJS4 Window的创建,头在左'
  }).show();
   
  Ext.create('Ext.Window',{
    width:400,
    height:230,
    x:500,
    y:10,
    plain: true,
    //指示标题头的位置,分别为 top,bottom,left,right,默认为top
    headerPosition: 'right',
    title: 'ExtJS4 Window的创建,头在右'
  }).show();
   
  Ext.create('Ext.Window',{
    width:400,
    height:230,
    x:10,
    y:300,
    plain: true,
    //指示标题头的位置,分别为 top,bottom,left,right,默认为top
    headerPosition: 'bottom',
    title: 'ExtJS4 Window的创建,头在底'
  }).show();
  var win = Ext.create('Ext.Window',{
    width:400,
    height:230,
    x:500,
    y:300,
    plain: true,
    //指示标题头的位置,分别为 top,bottom,left,right,默认为top
    headerPosition: 'top',
    title: 'ExtJS4 Window的创建'
  });
  win.show()
这是神马;
});
</script>
</head>

<body>
</body>
</html>
hxy 发表于 2011-7-25 10:35 | 显示全部楼层
呵呵,等着就等着....
jinchang 发表于 2011-7-29 10:09 | 显示全部楼层
啊...刚回来啊...
芷馨 发表于 2011-7-29 10:10 | 显示全部楼层
谢谢分享了!
芷馨 发表于 2011-7-29 10:55 | 显示全部楼层
老大,我好崇拜你哟
紫衿 发表于 2011-8-10 10:50 | 显示全部楼层
激动了就不好办了..
fl 发表于 2011-8-16 10:11 | 显示全部楼层
呵呵  我傻了‘~~哈哈
走就走吧 发表于 2011-8-18 13:45 | 显示全部楼层
看起来好~~像啊~~~~~
东逝水 发表于 2011-10-16 11:05 | 显示全部楼层
reg2011 发表于 2011-6-17 20:48
窗口实例--www.51myit.com


学习学习下。。。
lwqhp22 发表于 2011-10-31 09:11 | 显示全部楼层
本帖最后由 lwqhp22 于 2011-10-31 09:12 编辑

楼主厉害,希望以后有更多的4.0例子,我一定关注你的空间
全力兔子 发表于 2012-3-8 20:58 | 显示全部楼层
很棒的例子  学习
悄悄豆 发表于 2012-3-15 16:26 | 显示全部楼层
非常的感谢。为什么WINDOW的例子在IE里可以显示,在FIREFOX里不显示。还有修改anchor没有变化。希望楼主再多发些例子。{:soso_e100:}
您需要登录后才可以回帖 登录 | 成为会员

本版积分规则

QQ|手机版|小黑屋|网站帮助|职业IT人-IT人生活圈 ( 粤ICP备12053935号-1 )|网站地图
本站文章版权归原发布者及原出处所有。内容为作者个人观点,并不代表本站赞同其观点和对其真实性负责,本站只提供参考并不构成任何投资及应用建议。本站是信息平台,网站上部分文章为转载,并不用于任何商业目的,我们已经尽可能的对作者和来源进行了通告,但是能力有限或疏忽造成漏登,请及时联系我们,我们将根据著作权人的要求立即更正或者删除有关内容。

GMT+8, 2024-4-28 18:10 , Processed in 0.192687 second(s), 32 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表