开发实例--查看文章
 
ExtJS的几个小技巧
发布时间:2009-4-5

一、如何禁用或者启用某个菜单

有的时候,有时会根据需要,启用或者禁用某个菜单项,在ExtJS中,可以通过如下的操作进行。

 

 

 1 Ext.onReady(function() {
 2     Ext.BLANK_IMAGE_URL = 'resources/images/default/s.gif';
 3     Ext.QuickTips.init();
 4     var tb = new Ext.Toolbar({
 5         applyTo: 'tb',
 6         width: 400
 7     });
 8     var styleMenu = new Ext.menu.Menu({
 9         items: [{
10             text: '主题选择',
11             id: 'style',
12             menu: new Ext.menu.Menu({
13                 items: [{
14                     text: '红色主题',
15                     checked: true,
16                     group: 'theme'
17                 }, {
18                     text: '蓝色主题',
19                     checked: false,
20                     group: 'theme'
21                 }, {
22                     text: '黑色主题',
23                     checked: false,
24                     group: 'theme'
25                 }]
26             })
27          }, {
28                 text: '启用主题',
29                 checked: true,
30                 checkHandler: function() { Ext.getCmp('style').setDisabled(!this.checked) }
31          }]
32     });
33     tb.add({ text: '主题', menu: styleMenu });
34 });

 

二、如何设置DateField的默认值。

设置DateField的默认值,可以直接给value属性赋值,如:value:  '01/01/2009',如果要设置默认值为当天的日期,可以如下设置:value: new Date

1             new Ext.form.DateField({
2                 id: 'df',
3                 fieldLabel: '日期',
4                 format: 'Y年m月d日',
5                 width: 150,
6                 //value: '01/01/2009'
7                 value: new Date
8             })

 

GridPanel使用之技巧

var grid = new Ext.grid.GridPanel([{
 2     cm: new Ext.grid.ColumnModel({
 3         header: '',
 4         dataIndex: '',
 5         //设置列显示值
 6         //v:当前列的值
 7         //params:当前列的参数
 8         //record:当前记录集
 9         renderer: function(v, params, record){}
10     }]),
11     view: new Ext.grid.GroupingView({
12         forceFit: true,
13         groupTextTpl: '{text} ([values.rs.length])',
14         //设置行样式
15         //record: 当前纪录集
16         //index: 行索引
17         //rowParams: 行参数
18         //store: 数据集
19         getRowClass: function(record, index, rowParams, store){
20             return 'style class'
21         }
22     })
23 });


9 
 


免费电影
设为首页
加入收藏
不吊线谷歌
©2008 MyExt.cn
本站文章来自互联网,仅供学习和研究使用,如有版权问题,请发送Email:myext@126.com.