按照需要,我们一般在Grid的上方放置一个toolbar,再在上面放一些输入控件做查询用,但是同时我们也需要在上面添加一些其他按钮,比如“新增”,“删除”,“修改”,“导出”等,但是这些按钮要是放置查询的那个tbar上的话,感觉不太好,最好将分成两排。
我们先看看截图:
代码如下:
//Grid其他代码省略
tbar : [{
xtype : 'hidden',
id : 'action',
value : 'QUERY_T_SYS_USER_ACTION'
}, '用户姓名: ', {
xtype : 'textfield',
id : 'description',
width : 120
}, new Ext.Toolbar.TextItem(" "),
'创建时间: ', {
id : 'itemDateFrom',
xtype : 'datefield',
format : 'Y-m-d',
readOnly : true
}, '至', {
id : 'itemDateTo',
xtype : 'datefield',
format : 'Y-m-d',
readOnly : true
}, '-', {
text : '查询',
iconCls : 'query',
handler : function() {
store.load({
params : {
start : 0,
limit : 25,
USER_NAME : Ext.get('description').dom.value,
action : Ext.get('action').dom.value
}
})
}
}],
listeners : {
'render' : function() {
var tbar = new Ext.Toolbar({
items : [{
text : '新增',
iconCls : 'add'
}, {
text : '修改',
iconCls : 'modify'
}, {
text : '删除',
iconCls : 'delete'
}, '-', {
text : '导出PDF',
iconCls : 'pdf'
}, {
text : '导出Excel',
iconCls : 'excel'
}, '-', {
text : '打印',
iconCls : 'print'
}]
});
tbar.render(grid.tbar);
}
}