Search code examples
angulardevextremedevextreme-angulardx-data-grid

Set default options of DxDataGrid


I have an angular application which has a lot of components using DxDataGrid, all of them have the same default options. Is it possible to set the default options somewhere at any settings file or something similar?


Solution

  • Use the dxDataGrid.defaultOptions method to set default configuration options for all DataGrid widgets. This method is static and you can call it in a constructor of the main component.

    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

    Answered in this question from DevExtreme support