kevin0796 2009-10-14 15:58
浏览 420
已采纳

ComboBox赋值问题

<script type="text/javascript">

Ext.onReady(function() {
Ext.QuickTips.init();
var username,password,usertype,code;
var usertype_store;
LoginWindow = Ext.extend(Ext.Window, {
title : '登陆系统',
width : 265,
height : 190,
closable:false,
collapsible : false,
defaults : {
border : false
},
buttonAlign : 'center',
/** createUserTypeStore : function(){
usertype_store=new Ext.data.GroupingStore({
fields : ['value', 'label'],
data : [['0', '管理员'], ['1', '代理'],['2','操作员']]
});
},*/
createFormPanel : function() {
return new Ext.form.FormPanel({
bodyStyle : 'padding-top:6px',
defaultType : 'textfield',
labelAlign : 'right',
labelWidth : 55,
labelPad : 0,
frame : true,
defaults : {
allowBlank : false,
width : 158
},
items : [username=new Ext.form.TextField({
cls : 'user',
name : 'username',
msgTarget : 'side',
fieldLabel : '帐号',
blankText : '帐号不能为空'
}), password=new Ext.form.TextField({
cls : 'key',
name : 'password',
fieldLabel : '密码',
msgTarget : 'side',
blankText : '密码不能为空',
inputType : 'password'
}),usertype=new Ext.form.ComboBox({ //ComboBox
cls:'user',
name:'usertype',
fieldLabel:'用户类型',
editable: false,
store:new Ext.data.JsonStore({
fields:['value','label'],
data:[['0','管理员'],['1','操作员']]
}),
valueField:'value',
displayField:'label',
msgTarget:'side',
blankText:'请选择用户类型'
}), {
cls : 'key',
name : 'randCode',
id : 'randCode',
fieldLabel : '验证码',
width : 100,
blankText : '验证码不能为空'
}]
});
},
login : function() {
this.fp.form.submit({
waitMsg : '正在登录......',
url : 'login.do?cmd=login',
success : function(form, action) {
window.location.href = './pages/main/index.html';
},
failure : function(form, action) {
form.reset();
if (action.failureType == Ext.form.Action.SERVER_INVALID)
Ext.MessageBox.alert('警告', action.result.errors.msg);
}
});
},
initComponent : function() {

    LoginWindow.superclass.initComponent.call(this);
    this.fp = this.createFormPanel();
    this.add(this.fp);
    this.addButton('登陆', this.login, this);
    this.addButton('重置', function() {
        this.fp.form.reset();
    }, this);

}

});
var win = new LoginWindow();

win.show();
var bd = Ext.getDom('randCode');
var bd2 = Ext.get(bd.parentNode);
bd2.createChild({
    tag : 'img',
    src : './pages/login/image.jsp',
    align : 'absbottom'
});

});

</script>

赋值显示不了???

  • 写回答

1条回答 默认 最新

  • iteye_20589 2009-10-14 16:13
    关注

    把JsonStore改为SimpleStore(如果是2.2的话),3.0则为ArrayStore
    另外加个
    mode:'local' 意思是从本地读取
    下面是你那comboBox的代码
    [code="java"]usertype=new Ext.form.ComboBox({ //ComboBox
    cls:'user',
    name:'usertype',
    fieldLabel:'用户类型',
    editable: false,
    mode : 'local',
    store:new Ext.data.SimpleStore({
    fields:['value','label'],
    data:[['0','管理员'],['1','操作员']]
    }),
    valueField:'value',
    displayField:'label',
    msgTarget:'side',
    blankText:'请选择用户类型'
    })[/code]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度