Ext中如何设置才能达到单选按钮和提示信息fieldLabel值在满足条件的时候同时显示或隐藏。
[code="java"]
//按钮
{
xtype:'radiogroup',
id : 'loc',
name : 'loc',
width: 300,
hidden : false,
fieldLabel:'', //这地方要不同的值,或隐藏 ?????
items : [
{boxLabel: '1', name: 'loc', inputValue: 1 },
{boxLabel: '2', name: 'loc', inputValue: 2 },
{boxLabel: '3', name: 'loc', inputValue: 3 },
{boxLabel: '4', name: 'loc', inputValue: 4 },
{boxLabel: '5', name: 'loc', inputValue: 5,checked: true}
]
}
[/code]
[code="java"]
//条件
selectRow = grid.getSelectionModel().getSelected();
if(selectRow.get('type') =='上海'){
Ext.getCmp('loc').fieldLabel=''; //这个if中倒底怎么写
}
[/code]
我要的结果是如果 type的值是'上海',那么页面就显示: 请选择地方 单选按钮1 单选按钮2 单选按钮3 单选按钮4
如果type不是上海,那么页面上的: 请选择地方 单选按钮1 单选按钮2 单选按钮3 单选按钮4 全都不显示
’请选择地方‘就是fieldLabel的值。请问这要实现这种功能应该怎么呢,着急。
我曾经是这么写的但不行。
[code="java"]
if(selectRow.get('type') =='上海'){
Ext.getCmp('loc').fieldLabel='请选择地方'; //1方式:这么写达不到要求,
// Ext.getCmp('loc').show(); //2方式:这么写按钮倒是不显示了,但文本 '请选择地方' 还是显示
}else{
Ext.getCmp('loc').fieldLabel=''; //1方式
// Ext.getCmp('loc').hide(); //2方式
}
[/code]
</head>
<body>
<div id="form"></div>
<script type="text/javascript">
Ext.onReady(function(){
var form = new Ext.form.FormPanel({
title: 'form',
frame: true,
layout:"form",
items: [{
xtype:'radiogroup',
id : 'loc',
name : 'loc',
width: 300,
hidden : false,
fieldLabel:'', //这地方要不同的值,或隐藏 ?????
items : [
{boxLabel: '1', name: 'loc', inputValue: 1 },
{boxLabel: '2', name: 'loc', inputValue: 2 },
{boxLabel: '3', name: 'loc', inputValue: 3 },
{boxLabel: '4', name: 'loc', inputValue: 4 },
{boxLabel: '5', name: 'loc', inputValue: 5,checked: true}
]
} ],
renderTo: 'form'
});
Ext.get('change').on('click', function() {
[color=red]form.items.item(0).el.dom.parentNode.parentNode.firstChild.innerHTML= '更改日期 :' [/color] });
});
我做的按钮 只是一个例子 展示如何动态改变 你难道不会变换一下??
if(selectRow.get('type') =='上海'){
Ext.getCmp('loc').el.dom.parentNode.parentNode.firstChild.innerHTML= '上海:'
}else if(selectRow.get('type') =='北京){
Ext.getCmp('loc').el.dom.parentNode.parentNode.firstChild.innerHTML= '北京:'
}else{
Ext.getCmp('loc').el.dom.parentNode.parentNode.firstChild.innerHTML= '' //隐藏
}
//当然不建议使用通过id获得此组件 (Ext.getCmp('loc'))
我的这个都成功了 不清楚你具体啥代码了
你的代码 设置大量的id属性 就不怕出问题嘛??
我就没通过id属性获得ext控件