iteye_9444 2010-08-03 19:04
浏览 735
已采纳

Ext的combox设置成只读的问题

Ext的combox设置成只读的,让别人不能下拉?但是要显示,如果加上disable:true的话,又无法把值传到后台?本人用的Ext版本是3.0的,下面是代码
var form1_id = new Ext.form.ComboBox({
id: 'form1_id',
name: 'id',
hiddenName: 'id',
fieldLabel: '*所属区域',
editable : false,

typeAhead: true,
lazyRender: true,
readOnly:true,

    mode: 'remote',
    store: new Ext.data.Store({
        proxy: new Ext.data.HttpProxy({
            url: '<c:url value="。。。。.do" />?action=id_load'
        }),
        reader: new Ext.data.JsonReader({
                root: 'data',
                id: 'id'
            }, 
            ['id', 'Name']
        )
    }),
     valueField: 'id',
    displayField: 'Name'

});

怎么设置让显示出来后别人只能看,而无法操作,同时值要传到后台?这里设置的 readOnly:true没用

  • 写回答

5条回答 默认 最新

  • works001 2010-08-05 10:40
    关注
        <script type="text/javascript">
    

    Ext.onReady(function(){
    var data = {"items":[{"name":"yyf123","password":"123","userId":1},{"name":"yyf345","password":"456","userId":2}],"result":2} ;

    var store = new Ext.data.JsonStore({
            autoLoad:true, 
            fields:[{name:'name',type:'String'},   
                    {name:'password',type:'String'},   
                    {name:'userId',type:'int'}   
            ], 
            root:'items',
            data: data
    });
    

    myComboBox = Ext.extend(Ext.form.ComboBox, {
    store: store,
    emptyText: '请选择',
    mode: 'local',
    triggerAction: 'all',
    maxHeight:80,
    valueField: 'userId',
    displayField: 'name',
    lastQuery:"",
    notShow:false, //加一个属性 默认为FALSE
    renderTo: 'combo',
    initComponent : function(config){
    Ext.apply(this,config)
    Ext.form.ComboBox.superclass.initComponent.call(this);
    },
    onTriggerClick : function(){
    //如果if为真 则直接return 下拉不出来
    if( this.readOnly || this.disabled || this.notShow){
    return;
    }
    if(this.isExpanded()){
    this.collapse();
    this.el.focus();
    }else {
    this.onFocus({});
    if(this.triggerAction == 'all') {
    this.doQuery(this.allQuery, true);
    } else {
    this.doQuery(this.getRawValue());
    }
    this.el.focus();
    }
    },
    HideCombo:function(b){ //加一个函数
    this.notShow = b;
    }

    })
    var combo = new myComboBox();

    Ext.get("show").on("click",function(){
                combo.HideCombo(false)
    
    
    })
    
    Ext.get("readOnly").on("click",function(){
        combo.HideCombo(true)
        combo.setEditable(false)
    })
    

    });



        <input type="button" id="show" value="能下拉">
    
    
        <input type="button" id="readOnly" value="不能下拉">
    
    
    </body>
    

    不知道这样 你满不满意

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 ubuntu系统下挂载磁盘上执行./提示权限不够
  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
  • ¥30 3天&7天&&15天&销量如何统计同一行
  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型