社区
Ajax
帖子详情
Extjs中的combobox的动态加载问题
boss0207
2007-10-25 01:12:13
想在Extjs的grid中添加combox,而这个combox是从数据库中动态取数据库里的东西,而不是静态的东西,请问怎么实现,最要有相关的代码和解释,主要就是用了ExtjsAPI里的哪些函数,具体点最好
...全文
12683
36
打赏
收藏
Extjs中的combobox的动态加载问题
想在Extjs的grid中添加combox,而这个combox是从数据库中动态取数据库里的东西,而不是静态的东西,请问怎么实现,最要有相关的代码和解释,主要就是用了ExtjsAPI里的哪些函数,具体点最好
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
36 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
lshq
2012-09-24
打赏
举报
回复
怎样动态改变proxy中的url值?4.0
hc459242451
2012-08-03
打赏
举报
回复
learning
qujianjiutian
2012-07-09
打赏
举报
回复
Ext.ux.form.ComboBox = Ext.extend(Ext.form.ComboBox, {
relationName : '',
pkFieldName : '',
bizObjClass : '',
action : '',
fieldLabel : '',
emptyText : '',
allowBlank : false,
mode : 'remote',
triggerAction : 'all',
// 当被选择时,显示全部的数据
displayField : '',
listWidth : 100,
width : 100,
valueField : '',
name : '',
forceSelection : false,
resizable : true,
typeAhead : true,
loadWhenRender : false,// 控件实例化后就开始搜索(如果selectFirstRow为true 则此设置无效)
selectFirstRow : false,// 默认选中第一条数据
totalRecords : 'total',
dataField:[],
// 'total'//查询结果记录数字段名
createStore : function() {
if (this.mode == 'remote') {
//debugger;
this.bizobj = eval('new ' + this.bizObjClass);
this.dataField.push(this.valueField);
this.dataField.push(this.displayField);
//this.saveInformation(this.bizobj);
this.store = new Ext.data.Store({
proxy : new CPC.ext.HttpProxy({
url : this.bizobj.getUrl()
}),
reader : new CPC.ext.BizObjReader({
record : this.relationName,
id : this.pkFieldName,
totalRecords : this.totalRecords
},this.dataField)
});
this.store.on('loadexception', this.onLoadError);
} else if (this.mode == 'local') {
this.displayField = 'text';
this.valueField = 'value', this.store = new Ext.ux.SimpleStore(
{
data : this.data
});
}
},
setCondition : function(obj) {
for (var i in obj) {
this.bizobj[i] = obj[i];
}
},
load : function(condition) {
//debugger;
if (this.mode == 'remote') {
this.store.removeAll();
this.bizobj = eval('new ' + this.bizObjClass);
if (condition) {
this.setCondition(condition);
}
this.saveInformation(this.bizobj);
this.store.load({
params : {
bizobj : this.bizobj,
action : this.action
}
});
if (this.selectFirstRow) {
this.store.on('load', function() {
Ext.each(this.store.data.items, function(
data) {
this.setValue(data
.get(this.valueField));
return false;
}, this);
}, this);
}
}
},
reload : function() {
if (this.mode == 'remote') {
this.store.load({
params : {
bizobj : this.bizobj,
action : this.action
}
});
}
},
reset : function() {
if (this.defaultValue) {
this.setValue(this.defaultValue);
} else {
Ext.ux.form.ComboBox.superclass.reset.call(this);
}
},
saveInformation : function(bizObj) {
},
initList : function() {
if (this.loadWhenRender == false)// 延时加载数据
this.load();
Ext.ux.form.ComboBox.superclass.initList.call(this, arguments);
},
getStore : function() {
return this.store;
},
isXType : function(xtype, shallow) {
if (typeof xtype == 'function') {
xtype = xtype.xtype;
} else if (typeof xtype == 'object') {
xtype = xtype.constructor.xtype;
}
return this.constructor.xtype == xtype;
},
destroy : function() {
this.bizobj = null;
this.store = null;
// 子类一定要调用父类的销毁方法
},
onDestroy : function name() {
this.destroy();
Ext.ux.form.ComboBox.superclass.onDestroy.call(this);
},
initComponent : function() {
this.init();
Ext.ux.form.ComboBox.superclass.initComponent.call(this);
},
setValue:function(value){
//如果远程数据还没有加载,在设值之前先加载一次
if ( this.store.getCount() == 0 ) {
this.store.on("load", function() {
Ext.ux.form.ComboBox.superclass.setValue.call(this, value);
}, this, {
single : false // 此处true、false有什么区别?
});
this.doQuery(this.allQuery, true);
} else {
Ext.ux.form.ComboBox.superclass.setValue.call(this, value);
}
},
init : function() {
//debugger;
if (this.selectFirstRow)
this.loadWhenRender = true;
this.createStore();
if (this.loadWhenRender) {// 默认选中首条数据
this.load();
}
// 子类一定要调用父类的初始化方法
}
});
Ext.reg('ecombobox', Ext.ux.form.ComboBox);
egewg3
2012-06-01
打赏
举报
回复
var areamanager_user_store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url:'areamanager/searchUser'}),
reader: new Ext.data.JsonReader({
totalProperty: 'totalProperty',
root: 'root'
}, [
{name: 'userid'},
{name: 'username'},
])
});
areamanager_user_store.load();
new Ext.form.ComboBox({
fieldLabel: 'Management Level',
name:'group_id',
forceSelection: true,
listWidth: 150,
store: comboOptions,
valueField:'userid',
displayField:'username',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
selectOnFocus:true,
allowBlank:false
});
zengjf1988
2012-04-11
打赏
举报
回复
for (var i = 0; i < dCfgSumStore; i++) {
var dCfgNameTemp = 'combobox' + i; //给每个ComBoBox不同的名字
// var storeNameTemp = 'dCfgVNNullStore' + i;
dCfgstoreArray[i].baseParams.dCfgName = dCfgVNotStore.getAt(i).get('dCfgName');
dCfgstoreArray[i].load();
dCfgNameTemp = new Ext.form.ComboBox({
name:'projectId',
id:'projectId' + i, //循环创建combobox时,id不能一样
allowBlank:false,
blankText:dCfgVNotStore.getAt(i).get('dCfgName')+'不允许为空',
fieldLabel:dCfgVNotStore.getAt(i).get('dCfgName'),
xtype:'combo',
store : dCfgstoreArray[i],
mode:'remote',
//pageSize:10,
//labelWidth:40,
displayField : 'dCfgValue',
valueField : 'dCfgValue',
forceSelection : true,
triggerAction : 'all',
editable : false
//listeners:{ beforequery :select_CfgValue}
});
zengjf1988
2012-04-11
打赏
举报
回复
for (var i = 0; i < dCfgSumStore; i++) {
var dCfgNameTemp = 'combobox' + i; //给每个ComBoBox不同的名字
// var storeNameTemp = 'dCfgVNNullStore' + i;
dCfgstoreArray[i].baseParams.dCfgName = dCfgVNotStore.getAt(i).get('dCfgName');
dCfgstoreArray[i].load();
dCfgNameTemp = new Ext.form.ComboBox({
name:'projectId',
id:'projectId' + i, //循环创建combobox时,id不能一样
allowBlank:false,
blankText:dCfgVNotStore.getAt(i).get('dCfgName')+'不允许为空',
fieldLabel:dCfgVNotStore.getAt(i).get('dCfgName'),
xtype:'combo',
store : dCfgstoreArray[i],
mode:'remote',
//pageSize:10,
//labelWidth:40,
displayField : 'dCfgValue',
valueField : 'dCfgValue',
forceSelection : true,
triggerAction : 'all',
editable : false
//listeners:{ beforequery :select_CfgValue}
});
rsredwolf
2012-03-22
打赏
举报
回复
有没有4.0的代码
josephSC
2012-03-22
打赏
举报
回复
var dataStore = combo.getStore();
dataStore.proxy.conn.url = 'new url';
combo.bindStore(dataStore);
jiangfullll
2012-03-16
打赏
举报
回复
var schemeStore = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({
url : contextPath
+ '/confAveragefare/ConfAveragefare!getScheme.do'
}),
autoLoad : true,
reader : readerBase,
listeners : {
'load' : function() {
if (this.getCount() >= 2) {
schemeCombo.setValue(this.getAt(1).get('id'));
schemeCombo.fireEvent('select');
}
}
}
});
schemeCombo = new Ext.form.ComboBox({
fieldLabel : 'æ¹æ¡éæ©',
hiddenName : 'schemeId',
triggerAction : 'all',
displayField : 'name',
store : schemeStore,
allowBlank : true,
typeAhead : true,
resizable : true,
valueField : 'id',
mode : 'remote',
anchor : '95%',
editable : false
})
jiangfullll
2012-03-16
打赏
举报
回复
[Quote=引用 2 楼 umbrella_yxs 的回复:]
我写了一个,可以定向到service,但是不知道为什么取不出数据,哪个会的也帮我看下!!!
JScript code
var groupStore = new Ext.data.Store({
url: 'getGroupStore.action',
reader:_jsonGroupReader
});
……
[/Quote]
在comboBox中添加属性mode:'remote'就可以了
lin345521167
2012-03-16
打赏
举报
回复
学习一下!
浩瀚11
2011-09-07
打赏
举报
回复
学习中
canguangup
2011-06-10
打赏
举报
回复
很有用,学习。。。
q272416700
2011-05-13
打赏
举报
回复
学习中
toss3000
2011-05-04
打赏
举报
回复
学习中
LazyCoder
2011-03-23
打赏
举报
回复
谢谢 虽然帮助 不大
liyue36427076845110
2011-03-23
打赏
举报
回复
学习!!!!!!!!!!!!!
hncdzyl
2011-02-12
打赏
举报
回复
每天回帖即可获得10分可用分!小技巧
greatmind829
2011-02-12
打赏
举报
回复
跑跑鱼
2010-08-28
打赏
举报
回复
每天回帖即可获得10分可用分!小技巧
加载更多回复(16)
Extjs
中
ComboBox
加载
并赋初值的实现方法
当需要为
ComboBox
加载
数据后进行赋初始选
中
项的话,如果是写在store.load()之后
在
combobox
控件
中
添加图标
首先在窗体
中
添加一个
comboBox
1和一个imageList(本例
中
带有三个图片) this.
comboBox
1.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
RIA编程-神奇的FLEX实战
基于浏览器的富客户端编程,界面比Juery easy ui和
extJS
的更漂亮,操作更灵活! 而且FLEX的大优势是采用RPC模式,比AJAX速度更快。在浏览器
中
播放视频,FLEX编程占据了垄断地位;FLEX还有push模式开发,是非常重要的技术!这套 视频的开发环境是:myEclipse10+Flash builder4.6
extjs
3.x
combobox
智能联想
extjs
的
combobox
功能很强大,通过它可以模糊查询,只要添加几个属性即可,网上找的代码有的不符合我的要求。 所以自己改了一些代码。
ExtJS
4
中
文教程2 开发笔记 chm
Edit Grid限制编辑
ExtJS
4 DirectStore post参数的变化以及应对方法
ExtJS
4 实例之数据包
ExtJS
4
中
动态
加载
的路径设置
Extjs
4 API文档阅读(一)——类系统(Class System)
Extjs
4 API文档阅读(三)——布局和容器
Extjs
4 API文档阅读(二)——MVC构架(上)
Extjs
4 API文档阅读(二)——MVC构架(下)
Extjs
4 API文档阅读(四)——Data
ExtJS
4 Grid组件
Extjs
4 TreeGrid
Extjs
4 TreePanel实例
ExtJs
4
动态
加载
Extjs
4 带复选框的树(Checkbox tree)
Extjs
4 新的布局方式
Extjs
4 锁定表头(Locking Grid)功能
Extjs
4.0 MVC实例
Extjs
4.0
动态
填充
combobox
数据
Extjs
4
中
up()和down()的用法
ExtJS
4学习笔记(一)---window的创建
ExtJS
4学习笔记(七)---带搜索的Grid(SearchGrid)
ExtJS
4学习笔记(三)---VBox的使用
ExtJS
4学习笔记(九)---
ExtJS
4 EditGrid(可编辑的Grid)
ExtJS
4学习笔记(二)---HBox的使用
ExtJS
4学习笔记(五)---Grid分页
ExtJS
4学习笔记(八)---Grid多选 全选
ExtJS
4学习笔记(六)---多表头Grid
ExtJS
4学习笔记(十)---
ExtJS
4图片验证码的实现
ExtJS
4学习笔记(十一)---TabPanel
ExtJS
4学习笔记(十三)---上传文件(upload)
ExtJS
4学习笔记(十二)---选项卡(tabs)
ExtJS
4学习笔记(十五)---Ext.data.Model
ExtJS
4学习笔记(十六)---
Combobox
三级联动
ExtJS
4学习笔记(十四)--- ComponentQuery
ExtJS
4学习笔记(四)---Grid的使用
Extjs
4开发笔记(三)——菜单的实现
Extjs
4开发笔记(二)——框架的搭建
Extjs
4开发笔记(五)——
动态
grid
Extjs
4开发笔记(四)——实现登录功能
Extjs
4开发笔记(一)——准备工作 关于
Extjs
4开发笔记(二)的补充说明 在
Extjs
4应用
中
使用Ext.Loader ======================================= 11条jquery常用技巧和方法整理列表 8个超棒的学习jQuery的网站 JQuery 1.5 getJSON 的使用 JQuery AJAX提交
中
文乱码的解决方案 Jquery css函数用法 JQuery
中
getJSON的使用方法 Jquery
中
显示隐藏的实现代码分析 JQuery全选功能的实现 JQuery特效——下拉菜单 JQuery系列教程之XPath选择符 JQuery系列教程之选择符 JQuery自动缩放页面
中
的图片 JQuery获取浏览器的高度和宽度 jquery获得和设置下拉框值的代码 基于jquery的跨域调用文件 ================================= 7款强大的Javascript网格插件 Javascript 汉字编码转换 Javascript 面向对象之封装 Javascript 面向对象之构造函数的继承 Javascript 面向对象之非构造函数的继承 JavaScript对象与继承教程之内置对象(下) JavaScript对象及继承教程(上) javascript正则表达式(一) javascript正则表达式(二) JavaScript的10种跨域共享方法 JavaScript类型总览 JavaScript获取文本框光标的像素位置 js函数match、exec、test、search、replace、split使用介绍 技巧:Javascript使用隐藏的new来创建对象 禁止页面全选复制,兼容多种浏览器
Ajax
52,797
社区成员
25,305
社区内容
发帖
与我相关
我的任务
Ajax
Web 开发 Ajax
复制链接
扫一扫
分享
社区描述
Web 开发 Ajax
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章