【问题标题】:Set default options of DxDataGrid设置 DxDataGrid 的默认选项
【发布时间】:2019-11-12 12:18:27
【问题描述】:

我有一个 Angular 应用程序,它有很多使用 DxDataGrid 的组件,它们都有相同的默认选项。是否可以在任何设置文件或类似文件中的某处设置默认选项?

【问题讨论】:

  • 你能把你已经写好的代码提供给我们吗?
  • 答案已关闭。我可以在 2 天内接受答案..
  • 酷!很高兴听到你解决了它。但无论如何,为了让 stackoverflow.com 有用,我们尝试发布自包含的问题和答案,而不是让人们点击链接来获取答案/问题,请在此处阅读所有内容:问题包括 minimum reproducible example 和答案,引用和复制粘贴在这里。
  • 对不起!更新了答案。谢谢

标签: angular devextreme devextreme-angular dx-data-grid


【解决方案1】:

使用 dxDataGrid.defaultOptions 方法为所有 DataGrid 小部件设置默认配置选项。该方法是静态的,可以在主组件的构造函数中调用。

export class AppModule {  
  constructor() {  
    DataGrid.defaultOptions({  
      options: {  
        showRowLines: true,  
        showColumnLines: false,  
        rowAlternationEnabled: false,  
        focusedRowEnabled: true,  
        allowColumnResizing: true,  
        noDataText: "",  
        scrolling: {  
          mode: "virtual"  
        },  
        sorting: {  
          mode: "single"  
        },  
        loadPanel: {  
          enabled: false  
        }
      }  
    });  
  }  
}

https://www.devexpress.com/Support/Center/Question/Details/T738119/datagrid-how-to-define-default-configuration-options-for-angular-components

从 DevExtreme 支持中回答了这个问题

【讨论】:

    猜你喜欢
    • 2019-11-12
    • 1970-01-01
    • 2015-09-19
    • 1970-01-01
    • 2012-11-19
    • 2017-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多