var op_menu = new Ext.menu.Menu({
id: 'op_menu',
items: [
{
text: '按专家姓名查找',
listeners:{
click:function(t,e){
searchByEmName();
}
}
},
{
text: '按身份证号码查找',
listeners:{
click:function(t,e){
searchByEmCode();
}
}
}
,
{
text: '按办公号码查找',
listeners:{
click:function(t,e){
searchByEmPhone();
}
}
}
,
{
text: '按工作单位查找',
listeners:{
click:function(t,e){
searchByEmUnit();
}
}
}
,
{
text: '按专家职务查找',
listeners:{
click:function(t,e){
searchByEmDuty();
}
}
},
{
text: '按工作年限查找',
listeners:{
click:function(t,e){
searchByEmYear();
}
}
}]
});
/*
* 3.5、"查找"按钮
*/
var btn_search = new Ext.Toolbar.Button(
{
id : "btn_search",
text : '简单查询',
tooltip : '使用我您能更快找到您要的信息!',
menu : op_menu,
iconCls : 'x-button-query'
});
/*
* 3.6、搜索框
*/
var text_Search = new Ext.form.TextField({
id : 'text_Search',
fieldLabel : ' 查找 ',
// grow : true,
hidden : true,
inputType : 'text',
fieldLabel : '查找数据',
width : 200,
// emptyText : '请输入',
enableKeyEvents : true,
listeners : {
keyup : function(f,e){
var newValue = text_Search.getValue().replace(/^\s+|\s+$/g,"");//正则表达式:去掉字符串的前后空格(中间的保留)
if(newValue!=oldValue){
store_Expert.reload();
}
oldValue = newValue;
},
focus : function (f){
text_Search.setValue('');
//oldValue='';
//store_Log.reload();
}
}
});
function searchByEmCode(){
keys = "emExpertCard";
Ext.getCmp("text_Search").show();
}
function searchByEmName(){
keys = "emExpertName";
Ext.getCmp("text_Search").show();
}
function searchByEmPhone(){
keys = "emExpertWorkPhone";
Ext.getCmp("text_Search").show();
}
function searchByEmUnit(){
keys = "emExpertWorkUnit";
Ext.getCmp("text_Search").show();
function searchByEmDuty(){
keys = "emExpertDuty";
Ext.getCmp("text_Search").show();
}
function searchByEmYear(){
keys = "emExpertWorkYear";
Ext.getCmp("text_Search").show();
}
我通过点击下拉菜单的选项来改变搜索框中的EmptyText,。。。。。。。。
很简单
[code="javascript"]
function searchByEmCode() {
keys = "emExpertCard";
var tf = Ext.getCmp("text_Search");
//下面两行用来设置默认值
tf.emptyText = 'searchByEmCode';
tf.setRawValue(tf.emptyText);
tf.show();
}
[/code]
text_Search.emptyText = 'new....' 看可以不
这个EmptyText 好像不能动态设置的吧 不明白你要把默认值设置动态有什么意思的呢
楼上的此言差矣.
看完楼主的代码,就应该知道动态设置的需求是什么了, 很正常的需求.
动态设置呢,看完我的回答,也应该知道如何做了.
2楼正解。