extjs中在GridPanel上添加一个搜索框 (文本框+按钮)怎么实现啊。。

extjs中在GridPanel上添加一个搜索框 (文本框+按钮)怎么实现啊。。,第1张

直接配置到工具条tbar里就行了:

var grid = new Ext.grid.GridPanel({

id: "grid1",

title: "GridPanel实例",

renderTo: "div1",

width: 500,

height: 300,

frame: true,

tbar: [{xtype:'label',text:'请输入关键词:'},{xtype:'textfield'山宴知,id:'KeyWord'},{text:'搜祥迅索',handler:function(){alert("搜索"逗消)}}

],

。。。。。//其它配置项

})

Ext.form.TriggerField 这个类是腊团 TextField的子类,你创建他的实例的时候可以设定下面判岩的属性.这个属性就是后面的图片

triggerClass : String

举个简单例子:

var comNam = new Ext.form.TriggerField({

name : 'comNam',

allowBlank: false,

blankText:"请点击文本框,进行公司选择",

fieldLabel :net.uni.in1.notBlankMark+ '公司名称',

readOnly:true,

cls:"ux-readOnly", //增加此样式,可以变灰

enableKeyEvents: true,

listeners:{

'focus': function(){

chooseCust()

}

},

triggerClass : 'view',

anchor : '掘局御90%'

})

}

单个按钮的话,参考如下,如果你是想通过两个按钮来表达差则开关稍作山液扩展即可:

new Ext.Button ({

    scale:'Large',

    fieldLabel :'是否',

    iconAlign : 'left',

    id : 'ynButton',

    tag : 'Y',

    handler :function(button){

    if(button.tag == 'N'){

      button.tag = 'Y'

      Ext.getDom(button.getId()).innerHTML ='Y图片'

   虚唯棚  }else if(button.tag=='Y'){

      button.tag= 'N'

      Ext.getDom(button.getId()).innerHTML ='N图片'

     }

    }

})

具体图片通过iconCls来切换,css要先在文件里定义好图片背景


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/11994361.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-20
下一篇 2023-05-20

发表评论

登录后才能评论

评论列表(0条)

保存