luoyifan 3 lat temu
rodzic
commit
a789328182
2 zmienionych plików z 71 dodań i 60 usunięć
  1. 15 0
      src/Defaults.ts
  2. 56 60
      src/controls/grid.js

+ 15 - 0
src/Defaults.ts

@@ -70,6 +70,13 @@ export const radio = {
 export const radiogroup = {
     labelAlign: 'right',
     labelWidth,
+    simpleValue: true,
+    layout: 'hbox',
+    defaults: {
+        xtype: 'radio',
+        name: 'type',
+        margin: '0 15 0 0'
+    },
 }
 
 export const form = {
@@ -84,6 +91,7 @@ export const form = {
 export const grid = {
     border: true,
     columnLines: true,
+    // rowLines: true
     plugins: {
         cellediting: {
             clicksToEdit: 1
@@ -100,6 +108,13 @@ export const grid = {
         checkOnly: false
     },
     pagination: true,
+    pageSize: 50,
+    pageSizeOption: ['20', '50', '100', '200', '300'],
+    hideFootbar: false,
+    hideRefresh: false,
+    hideExport: false,
+    hideAutoSize: false,
+    hideClearFilter: false,
     autoLoad: true,
     remoteSort: true,
     remoteFilter: true,

+ 56 - 60
src/controls/grid.js

@@ -29,74 +29,76 @@ export default function () {
 
             }, baseConfig(config, 'row-item'), config, grid)
 
-            const buttons = [
-                {
+            const buttons = []
+
+            if (!newConfig.hideExport) {
+                buttons.push({
                     xtype: 'button',
                     tooltip: '导出Excel',
                     iconCls: 'x-fa fa-download'
-                },
-                {
+                })
+            }
+            if (!newConfig.hideAutoSize) {
+                buttons.push({
                     xtype: 'button',
                     iconCls: 'x-fa fa-text-width',
                     tooltip: '自适应宽度',
                     listeners: {
                         click: this.autoSizeColumns
                     }
-                },
-                {
+                })
+            }
+            if (!newConfig.hideClearFilter) {
+                buttons.push({
                     xtype: 'button',
                     tooltip: '清空筛选',
                     iconCls: 'x-fa fa-filter',
                     handler: this.clearFilter
-                },
-                {
-                    xtype: 'button',
-                    tooltip: '清空筛选',
-                    iconCls: 'x-fa fa-cube',
-                    handler: this.test
-                }
-            ]
-
-            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: 50,
-                            valueField: undefined,
-                            displayField: undefined,
-                            hideClear: true,
-                            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
-                    ]
+            }
+
+            if (!newConfig.hideFootbar) {
+                if (newConfig.pagination) {
+                    newConfig.bbar = new Ext.PagingToolbar({
+                        pageSize: newConfig.pageSize,
+                        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: 50,
+                                valueField: undefined,
+                                displayField: undefined,
+                                hideClear: true,
+                                store: newConfig.pageSizeOption,
+                                listeners: {
+                                    change: (sender, nv, ov) => {
+                                        this.store.pageSize = nv;
+                                        this.store.loadPage(1);
+                                    }
+                                }
+                            },
+                            ...buttons
+                        ]
+                    })
+                } else {
+                    newConfig.bbar = {
+                        xtype: 'toolbar', overflowHandler: 'menu',
+                        items: [
+                            ...buttons
+                        ]
+                    }
                 }
             }
 
@@ -279,12 +281,6 @@ export default function () {
             sender.up('grid').filters.clearFilters();
         },
 
-        test(sender) {
-            const grid = sender.up('grid')
-            // grid.refreshData()
-            // console.log('grid', grid)
-        },
-
         setLoading(value) {
             if (value) {
                 this.mask('读取中')