|
@@ -1,7 +1,6 @@
|
|
|
import _ from 'lodash'
|
|
|
import {grid} from '../Defaults'
|
|
|
import {baseConfig} from "./base";
|
|
|
-import {dataSourceReload} from "../DataSourceHelper";
|
|
|
|
|
|
export default function () {
|
|
|
const cc = Ext.grid.Panel.prototype.constructor
|
|
@@ -13,6 +12,84 @@ export default function () {
|
|
|
|
|
|
}, baseConfig(config, 'row-item'), config, grid)
|
|
|
|
|
|
+ const buttons = [
|
|
|
+ {
|
|
|
+ xtype: 'button',
|
|
|
+ tooltip: '导出Excel',
|
|
|
+ iconCls: 'x-fa fa-file-excel-o'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ xtype: 'button',
|
|
|
+ iconCls: 'x-fa fa-columns',
|
|
|
+ tooltip: '自适应宽度',
|
|
|
+ listeners: {
|
|
|
+ click: (sender) => {
|
|
|
+ const grid = sender.up('grid')
|
|
|
+ // const columns = grid.columns;
|
|
|
+ // for (let i = 0; i < columns.length; i++) {
|
|
|
+ // const column = columns[i];
|
|
|
+ // grid.getView().autoSizeColumn(column);
|
|
|
+ // column.setWidth(column.getWidth() + 5);
|
|
|
+ // }
|
|
|
+ for (let i = 1; i < grid.headerCt.getColumnCount(); i++) {
|
|
|
+ grid.headerCt.getGridColumns()[i].autoSize(i);
|
|
|
+ grid.headerCt.getGridColumns()[i].setWidth(grid.headerCt.getGridColumns()[i].getWidth() + 15);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ xtype: 'button',
|
|
|
+ tooltip: '清空筛选',
|
|
|
+ iconCls: 'x-fa fa-filter',
|
|
|
+ handler: (sender) => {
|
|
|
+ sender.up('grid').filters.clearFilters();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+
|
|
|
+ if (newConfig.pagination) {
|
|
|
+ newConfig.bbar = new Ext.PagingToolbar({
|
|
|
+ pageSize: 50,
|
|
|
+ displayInfo: true,
|
|
|
+ store: this.store,
|
|
|
+ emptyMsg: '没有记录',
|
|
|
+ items: [
|
|
|
+ {
|
|
|
+ xtype: 'combobox',
|
|
|
+ tooltip: '分页',
|
|
|
+ queryMode: 'local',
|
|
|
+ editable: false,
|
|
|
+ allowBlank: true,
|
|
|
+ labelAlign: 'right',
|
|
|
+ width: 90,
|
|
|
+ // labelWidth: 30,
|
|
|
+ listConfig: {
|
|
|
+ minWidth: null
|
|
|
+ },
|
|
|
+ value: 20,
|
|
|
+ valueField: undefined,
|
|
|
+ displayField: undefined,
|
|
|
+ store: ['20', '50', '100', '200', '300'],
|
|
|
+ listeners: {
|
|
|
+ change: (sender, nv, ov) => {
|
|
|
+ this.store.pageSize = nv;
|
|
|
+ this.store.loadPage(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ ...buttons
|
|
|
+ ]
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ newConfig.bbar = {
|
|
|
+ xtype: 'toolbar', overflowHandler: 'menu',
|
|
|
+ items: [
|
|
|
+ '->',
|
|
|
+ ...buttons
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
cc.call(this, newConfig)
|
|
|
},
|