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 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式