Extjs.GridPanel 显示多行工具栏 (tbar)

js文件。。


Ext.onReady(function() {

//初始化数据
var proData = {
records : [{
proName : "cocobra 居家内衣系列"
}, {
proName : "cocobra 休闲内衣系列"
}]
}


var proCreate = new Ext.data.Record.create([{
name : "proName",
mapping : "proName",
type : "string"
}]);

var fields = [{
name : 'proName',
mapping : 'proName'
}];


var proStore = new Ext.data.JsonStore({
fields : fields,
data : proData,
root : 'records'
});

var rowNum = new Ext.grid.RowNumberer(); //添加行号
var projectColumn = new Ext.grid.ColumnModel([rowNum, {
header : "项目名称",
width : 160,
dataIndex : "proName",
id : "proName",
sortable : true //设置排序
}]);

//第二個工具欄
var tbar2 = new Ext.Toolbar({
renderTo : Ext.grid.GridPanel.tbar,// 其中grid是上边创建的grid容器
items : [{
text : '添加',
iconCls:'addBtn'
}, {
xtype : "tbseparator"
}, {
text : "删除",
iconCls : "deleteBtn" //图片样式, 需要自己寫css樣式,引入手寫的css,如果用自带会因为浏览器不兼容而不显示图片
}, {
xtype : "tbseparator"
}, {
text : "删除全部",
iconCls:'deleteBtn'
}, {
xtype : "tbseparator"
}, {
text : '保存',
iconCls:'saveBtn'
}]

});

var tbar3 = new Ext.Toolbar({
renderTo: Ext.grid.GridPanel.tbar,
items:[new Ext.form.TextField({
fieldLabel:"测试"
// width:100
//height:30
})]
})


var projectGrid = new Ext.grid.GridPanel({
renderTo : "hello",
title : "项目管理",
widht : 180,
height : 200,
cm : projectColumn,
store : proStore,
autoScroll : true, // 内容溢出时产生滚动条
tbar : [new Ext.form.ComboBox({
store : ["喜羊羊与灰太狼", "cocobra"], //給ComboBox添加數據
emptyText : '请选择供应商',
id : "provider",
name : "provider",
editable : false //是否允許輸入

})],
listeners : { //將第二個bar渲染到tbar裏面,通过listeners事件
'render' : function() {
tbar2.render(this.tbar);
tbar3.render(this.tbar);
}
}
});
});




--- 在按钮旁边添加图片的css样式
.deleteBtn {
background-image: url(../images/default/dd/drop-no.gif) !important;
margin-right:5px;
background-repeat: no-repeat;
}

.addBtn {
background-image: url(../images/default/dd/drop-add.gif) !important;
margin-right:5px;
background-repeat: no-repeat;
}

.saveBtn {
background-image: url(../images/default/dd/drop-yes.gif) !important;
margin-right:5px;
background-repeat: no-repeat;
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可以使用 Ext.grid.feature.Grouping 插件来进行单元格合并。以下是示例代码: ``` Ext.create('Ext.grid.Panel', { title: 'My Grid Panel', store: myStore, columns: [ { text: 'Name', dataIndex: 'name', flex: 1 }, { text: 'Age', dataIndex: 'age', flex: 1 }, { text: 'Salary', dataIndex: 'salary', flex: 1 } ], features: [{ ftype: 'grouping', groupHeaderTpl: '{columnName}: {name} ({rows.length})', hideGroupedHeader: true, startCollapsed: true, groupByText: 'Group by this field' }], renderTo: Ext.getBody() }); ``` 在上述代码中,我们创建了一个包含三列的 GridPanel,并使用 Ext.grid.feature.Grouping 插件进行了单元格合并。我们使用 groupHeaderTpl 属性来指定分组的标题,hideGroupedHeader 属性来隐藏已分组的列的标题,startCollapsed 属性来指定分组初始时是否折叠,groupByText 属性来指定分组菜单项的文本。 如果您想要根据特定的列进行分组和合并,则可以使用 groupField 属性来指定要分组的列的名称。例如: ``` Ext.create('Ext.grid.Panel', { title: 'My Grid Panel', store: myStore, columns: [ { text: 'Name', dataIndex: 'name', flex: 1 }, { text: 'Age', dataIndex: 'age', flex: 1 }, { text: 'Salary', dataIndex: 'salary', flex: 1 } ], features: [{ ftype: 'grouping', groupHeaderTpl: '{columnName}: {name} ({rows.length})', hideGroupedHeader: true, startCollapsed: true, groupByText: 'Group by this field', groupField: 'age' }], renderTo: Ext.getBody() }); ``` 在上述代码中,我们将 groupField 属性设置为 'age',这意味着我们将根据 'age' 列进行分组和合并。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值