导航:首页 > 编程语言 > extjs2实例

extjs2实例

发布时间:2025-05-26 06:09:44

① 如何让Extjs4.1中的treegrid和treestore实现分页

Extjs treeGrid分页实例,项目中用到,拿出来跟大家分享一下,主要是通过两个store实现。

[javascript] view plain
ProTreeGrid = Ext.extend(Ext.tree.Panel, {
_baseParam : {
process : '项目立项',
isShow : 'true',
start : 1
},
constructor : function(_config) {
if (_config == null)
_config = {};
Ext.apply(this, _config);

this.store1 = Ext.create('Ext.data.JsonStore', {
autoLoad : true,
pageSize : basicConstant.LIMIT,
proxy : {
type : 'ajax',
url : "xmgl/pro-info-manage!page.action",
extraParams : this._baseParam,
reader : {
type : 'json',
root : 'rows',
totalProperty : "totalCount"
}
},
model : 'ProInfo'
});

this.store = Ext.create('Ext.data.TreeStore', {
model : 'ProInfo',
proxy : {
type : 'ajax',
url : 'xmgl/pro-info-manage.action'
},
folderSort : true,
listeners : {
'beforeload' : {
fn : function(_s, _op, _e) {
this._baseParam.limit = basicConstant.LIMIT;
_s.proxy.extraParams = this._baseParam;
},
scope : this
}
}
});

this['selModel'] = Ext.create('Ext.selection.TreeModel', {
mode : 'SINGLE',
listeners : {
'selectionchange' : {
fn : this.selectionChangeHandler,
scope : this
}
}
});
this['columns'] = [ {
xtype : 'treecolumn',
text : '项目性质',
flex : 1,
sortable : true,
dataIndex : 'proClass'
}, {
text : '项目名称',
flex : 2.5,
dataIndex : 'proName',
sortable : true
}, {
text : '流程状态',
flex : .75,
dataIndex : 'process',
sortable : true
}, {
text : '项目时间',
xtype : 'datecolumn',
format : 'Y-m-d',
dataIndex : 'crTime',
sortable : true,
flex : .85
}, {
text : '项目编号',
flex : 1,
dataIndex : 'proNo',
sortable : true
}, {
text : '项目单位',
flex : 1,
dataIndex : 'unit',
sortable : true
}, {
text : '优先级',
flex : .6,
dataIndex : 'priority',
sortable : true
}, {
text : '项目类型',
flex : .75,
dataIndex : 'proType',
sortable : true
}, {
text : '项目内容',
flex : 2,
dataIndex : 'proContent',
sortable : true
}, {
text : '附件数',
flex : .6,
dataIndex : 'fileCount',
sortable : true
} ]
ProTreeGrid.superclass.constructor.call(this, {
useArrows : true,
height : this._height,
width : this._width,
autoScroll : true,
rootVisible : false,
dockedItems : [ {
_treeGrid : this,
xtype : 'pagingtoolbar',
id : 'PROTREEGRID_PAGEBAR',
store : this.store1,
dock : 'bottom',
displayInfo : true,
listeners : {
change : function(obj, pdata, options) {
if(this._treeGrid._baseParam.start==pdata.currentPage)
return;
this._treeGrid._baseParam.start = pdata.fromRecord;
this._treeGrid._baseParam.limit = basicConstant.LIMIT;
this._treeGrid.store.load( {
params : this._treeGrid._baseParam
});
}
}
} ],
viewConfig : {
stripeRows : true,
enableTextSelection : true,
getRowClass : function(record) {
if (record.get("proClass") == '收入项目') {
return 'srcss';
} else if (record.get("proClass") == '支出项目') {
return 'zccss';
}
}
},
tbar : new Ext.toolbar.Toolbar( {
id : 'TBAR_PROTREEGRID',
items : [ new ProClassQueryCombo( {
width : 140,
labelWidth : 60
}), '-', '项目名称:', {
xtype : 'textfield',
width : 70
}, '无分项总体项目显示:', {
xtype : 'checkbox',
checked : true,
width : 70
}, {
text : "查询",
icon : 'images/icons/search.gif',
handler : this.onSearch,
scope : this
}, {
text : "重置",
icon : 'images/icons/del.gif',
handler : this.onReset,
scope : this
}, {
text : "高级查询",
icon : 'images/icons/search.gif',
handler : this.onAdvSearch,
scope : this
} ]
})
});
},
selectionChangeHandler : function() {
},
reLoadData : function() {
this.store.load( {
params : this._baseParam
});
this.store1.load( {
params : this._baseParam
});
},
onSearch : function() {
var _param = {};
var _tbar = Ext.getCmp('TBAR_PROTREEGRID');
_param.process = _tbar.items.items[0].value;
_param.proClass = _tbar.items.items[2].value;
_param.proName = _tbar.items.items[5].value;
_param.isShow = _tbar.items.items[7].value;
// this.store1.load(1);
this._baseParam = _param
this.reLoadData();
},
onReset : function() {
var _tbar = Ext.getCmp('TBAR_PROTREEGRID');
_tbar.items.items[0].setValue('项目立项');
_tbar.items.items[2].setValue('');
_tbar.items.items[5].setValue('');
this._baseParam = {
process : '项目立项',
isShow : 'false'
};
},
onAdvSearch : function() {
new ProQueryWin( {
_grid : this,
_process : '项目立项'
}).show();
}

});

② extjs的panel组件怎么使用

//html代码
<div id="container">
</div>

//js代码
var p = new Ext.Panel({
title: 'My Panel',//标题
collapsible:true,//右上角上的那个收缩按钮,设为false则不显示
renderTo: 'container',//这个panel显示在html中id为container的层中
width:400,
height:200,
html: "<p>我是内容,我包含的html可以被执行!</p>"//panel主体中的内容,可以执行html代码
});

因为panel组件的子类组件包括TabPanel,GridPanel,FormPanel,TreePanel组件,所以非常有必要介绍Panel组件的配置参数和相关的属性、方法。

//配置参数(只列举部分常用参数)
1.autoLoad:有效的url字符串,把那个url中的body中的数据加载显示,但是可能没有样式和js控制,只是html数据
2.autoScroll:设为true则内容溢出的时候产生滚动条,默认为false
3.autoShow:设为true显示设为"x-hidden"的元素,很有必要,默认为false

4.bbar:底部条,显示在主体内,//代码:bbar:[{text:'底部工具栏bottomToolbar'}],
5.tbar:顶部条,显示在主体内,//代码:tbar:[{text:'顶部工具栏topToolbar'}],
6.buttons:按钮集合,自动添加到footer中(footer参数,显示在主体外)//代码:buttons:[{text:"按钮位于footer"}]
7.buttonAlign:footer中按钮的位置,枚举值为:"left","right","center",默认为right

8.collapsible:设为true,显示右上角的收缩按钮,默认为false
9.draggable:true则可拖动,但需要你提供操作过程,默认为false

10.html:主体的内容
11.id:id值,通过id可以找到这个组件,建议一般加上这个id值
12.width:宽度
13.height:高度
13.title:标题

14.titleCollapse:设为true,则点击标题栏的任何地方都能收缩,默认为false.

15.applyTo:(id)呈现在哪个html元素里面
16.contentEl:(id)呈现哪个html元素里面,把el内的内容呈现
17.renderTo:(id)呈现在哪个html元素里面
//关于这三个参数的区别(个人认为:applyTo和RenderTo强调to到html元素中,contentEl则是html元素到ext组件中去):
英文如下(本人英语poor,不敢乱翻译):
contentEl - This config option is used to take existing content and place it in the body of a new panel. It is not going to be the actual panel itself. (It will actually the innerHTML of the el and use it for the body). You should add either the x-hidden or the x-hide-display CSS class to prevent a brief flicker of the content before it is rendered to the panel.
applyTo - This config option allows you to use pre-defined markup to create an entire Panel. By entire, I mean you can include the header, tbar, body, footer, etc. These elements must be in the correct order/hierarchy. Any components which are not found and need to be created will be autogenerated.
renderTo - This config option allows you to render a Panel as its created. This would be the same as saying myPanel.render(ELEMENT_TO_RENDER_TO);
哪位大人帮忙翻译下...
考虑到入门,方法事件会在以后的文章中以实例穿插。
1.可拖动的panel实例
下面我们做个可拖动panel例子来熟悉下panel这个最基本的组件.

//html代码
..无..

//下面创建一个允许拖动的panel,但是拖动的结果不能保存
var p=new Ext.Panel({
title: 'Drag me',
x: 100,
y: 100,
renderTo: Ext.getBody(),//x,y,renderTo:Ext.getBody()初始化panel的位置
floating: true,//true
frame: true,//圆角边框
width: 400,
height: 200,
draggable:true
}).show();//在这里也可以不show()
但是还不能拖到其他的地方,我们需要改写draggable:

draggable: {
insertProxy: false,//拖动时不虚线显示原始位置

onDrag : function(e){
var pel = this.proxy.getEl();
this.x = pel.getLeft(true);
this.y = pel.getTop(true);//获取拖动时panel的坐标
},
endDrag :

function(e){
this.panel.setPosition(this.x, this.y);//移动到最终位置
}
}
实现了可保存的拖动

拖动的时候阴影还在原位置,我们再在draggable中的onDrag事件中添加代码:

var s = this.panel.getEl().shadow;
if (s) {
s.realign(this.x, this.y, pel.getWidth(), pel.getHeight());
}
//shadow的realign方法的四个参数,改变shadow的位置大小属性
最后这个可拖动的panel的代码为:

var p=new Ext.Panel({
title: 'Drag me',
x: 100,
y: 100,
renderTo: Ext.getBody(),
floating: true,
frame: true,
width: 400,
height: 200,
draggable: {
insertProxy: false,
onDrag :

function(e){
var pel = this.proxy.getEl();
this.x = pel.getLeft(true);
this.y = pel.getTop(true);

var s = this.panel.getEl().shadow;
if (s) {
s.realign(this.x, this.y, pel.getWidth(), pel.getHeight());
}
},
endDrag : function(e){
this.panel.setPosition(this.x, this.y);
}
}
})
//效果图片我就不贴出来了
2.带顶部,底部,脚部工具栏的panel

var p=new Ext.Panel({
id:"panel1",
title:"标题",
collapsible:true,
renderTo:"container",
closable:true,
width:400,
height:300,
tbar:[{text:"按钮1"},{text:"按钮2"}], //顶部工具栏
bbar:[{text:"按钮1"},{text:"按钮2"}], //底部工具栏
html:"内容",
buttons:[{text:"按钮1"},{text:"按钮2"}] //footer部工具栏
});

我们已经在各种工具栏上添加了按钮,但是却没有激发事件,下面我们来添加按钮事件代码:

tbar:[{text:"按钮1",handler:function(){Ext.MessageBox.alert("我是按钮1","我是通过按钮1激发出来的弹出框!")}},{text:"按钮2"}],
//改写tbar,添加handler句柄,点击顶部工具栏上按钮1,弹出提示框,效果图大家想象下,就不贴出来了
当然,一般情况下,我们只要一个工具栏,这里只是为了演示!
3.panel工具栏

//添加下面的代码到panel配置参数中
tools:[{id:"save"},{id:"help"},{id:"up"},{id:"close",handler:function(){Ext.MessageBox.alert("工具栏按钮","工具栏上的关闭按钮时间被激发了")}}],
//id控制按钮,handler控制相应的事件
//id的枚举值为:
toggle (collapsable为true时的默认值)
close
minimize
maximize
restore
gear
pin
unpin
right
left
up
down
refresh
minus
plus
help
search
save
print

③ easyui和extjs哪个好

作为ExtJs和EasyUI都用得很熟练的一个老资格程序员,我发表一下我的看法。

首先两个框架的组件都很丰富,商业应用都要收费。ExtJS的动态性和扩展性更好,从使用效果看,easyui的组件相对体验更好一点。

ExtJS

优点:1.完全开源,我说的开源的意思并不是说不收费。

2.我非常赞赏它的架构设计,完全的面向对象的组件化设计。所有的组件都是从一些基础的组件派生出来的,并且提供了overide,extend等扩展方式,可以说能够任意扩展。可能一些半桶水的人觉得ExtJS很难用,那是因为他们只懂皮毛。

3.ExtJS的文档和实例做得比EasyUI要好得多,基础比较好的开发人员只用看官方的文档、demo、适当参考源码就能够完成任何工作,遇到问题完全不用去网络或论坛问其他人。

4.可以完全动态开发,代码都写在JS文件里,不像ExtJS那样非得在页面放一个DOM元素。所以可以自己定制组件在任意页面引用,复用性好。

缺点:1.可能太多人用,造成审美疲劳,反正我看腻了它的界面,自己定制界面主题有太难。

2.可能因为它太庞大,不像easyUI那样基于页面已有的HTML

DOM渲染,所以一般人觉得比较难(但是话有说会来,如果使用者的水平高的话,这其实也是也是它的优点。因为你要是在同一个界面点击不同按钮要动态显示各种各样不同的window、form等等的话,只要把这些JS引用到当前页面就可以吧,见上述优点4)。

easyui

优点:

1.在页面的DOM元素加一些属性然后加几行JS就可以动态构造出相应的组件。开发方式相对ExtJS直观和简洁一些。

2.组件相对体验更好一点,界面好像跟干净简洁。

缺点:1.半开源,对于一个高手来说看不到源代码是很痛苦的,事,因为他们总有这样那样的扩展需求。

2.一定要在页面上放置相应的DOM元素才能渲染(如果不对dom元素设置隐藏的话,在页面没有渲染过程中会显示一堆乱七八糟的东西)所以无法自己定制组件在其他页面引用,要复用的话得搬砖一样把JS和DOM都复制过来,遇到非常复杂的页面那是相当杂乱和痛苦的。

④ extjs中在GridPanel上添加一个搜索框 (文本框+按钮)怎么实现啊。。

直接配置到工具条tbar里就行了:
var grid = new Ext.grid.GridPanel({
id: "grid1",
title: "GridPanel实例",
renderTo: "div1",
width: 500,
height: 300,
frame: true,
tbar: [{xtype:'label',text:'请输入关键词:'},{xtype:'textfield',id:'KeyWord'},{text:'搜索',handler:function(){alert("搜索");}}
],
。。。。。//其它配置项
});

⑤ extjs的作用

extjs主要功能:
1、网格
大型数据页面的无限/缓冲滚动功能得到很大改进。同时,对于网格的“锁定”功能,新增了锁定和未锁定两种状态。
2、布局
在布局上,通过避免浏览器回流来加快访问速度(浏览器回流,指浏览器为了重新渲染部分或全部的文档而重新计算文档中元素的位置和几何结构的过程)。同时,新增了“边界”布局方式。收缩包围的宽度问题,以前是用特定组件来处理,现在改为用核心组件来处理。
3、核心组件
XTemplates和方法重写功能得到显著改善。Ext.override现在开始支持重写实例方法,并且,可以通过使用标准的callParent函数来访问被重写的方法。
此外,4.1版本开始支持通过使用函数名来实现事件监听器。

⑥ 有没有ext gwt、ExtJS相关介绍、教程之类的书(出版的)介绍一下

最近也在用gxt(也就是ext gwt)做项目,但gxt在国内明显没有人气,中文的教程一本回没有,英文的有一本《答Developing with Ext GWT Enterprise RIA Development》,可以在淘宝上买到。主要还是靠论坛,GXT的技术支持(花钱买的),以及gxt提供的demo进行学习和开发的。
说实话我还是很喜欢gxt的,毕竟我不是很精通javascript。GXT最大的问题还是在于多浏览器的兼容性问题,特别是IE。这也可能不是GXT的问题而是GWT的问题。

ext js 的话除了楼上的推荐一本《JavaScript凌厉开发—Ext JS 3详解与实践》。如果你要买《深入浅出ext》,一定要买第二版,引入了Ext JS最新版本3.2的新特性。第一版是没有的。如果你有心更深入,可以读这个《EXTJS 源码分析与开发实例宝典》,分析ext js源代码,读懂了绝对牛人。

关于gxt有什么问题可以一起交流下,干了半年多还是略有心得的。

阅读全文

与extjs2实例相关的资料

热点内容
编程里边百分号什么意思 浏览:691
网络电视包年开通了怎么取消 浏览:130
班级网站php 浏览:157
问号文件名后缀是rar 浏览:544
文件管理上的图片在哪里 浏览:691
瞳孔定位用什么数据集测试 浏览:158
为什么文件夹老是乱 浏览:228
刀塔传奇版本历史 浏览:425
qq密码查看器2013最新版 浏览:84
如何用ps改扫描文件大小 浏览:570
为什么有数学能力和编程思维 浏览:277
vb获取宽带密码 浏览:924
qq邮箱访问受限信用卡 浏览:420
中国武器是用什么语言编程的 浏览:169
doc文件下载软件 浏览:20
惠普电脑优盘装系统教程 浏览:14
描述文件信任会中毒吗 浏览:79
tbf数据库怎么开 浏览:436
网络互动的形式 浏览:546
怎样打开qq设置默认浏览器下载文件夹 浏览:996

友情链接