Search code examples
angulartypescriptdevextremedevextreme-angulardx-data-grid

How to put the dx-button beside dxo-export?


Export-button/dxo-export is part of dx-data-grid. I want to make these two dx-buttons in parallel with dxo-export button and make them right align too. So, dx-buttons and dxo-export button have same line and align. enter image description here

This is my code. Dx-button is outside of dx-data-grid. So I thought thats why the buttons can't be together

  <dx-button id="gridRealistSelected" 
    icon="fas fa-clipboard-check" 
    [height]="34" [width]="40">
  </dx-button>
  <dx-button id="gridSharePlan" 
    icon="fa fa-share-alt" 
    [height]="34" [width]="40">
  </dx-button>

  <dx-data-grid id="gridContainer" 
    keyExpr="id"
    [dataSource]="shoppingPlan">

    <dxo-export 
      fileName="Rencana Belanja"
      [enabled]="true"  
      [allowExportSelectedData]="false">
    </dxo-export>

    <dxi-column 
      dataField="ket" 
      caption="Keterangan">
    </dxi-column>
    <dxi-column 
      dataField="harga" 
      caption="Harga">
    </dxi-column>
  </dx-data-grid>

Solution

  •   onToolbarPreparing(e){
        this.gridElement = e.element;
        this.toolbarItems = e.toolbarOptions.items;
    
        this.toolbarItems.unshift({
          name: 'realistPlanButton',
          location: 'after',
          widget: 'dxButton',
          options: {
            hint: 'Realisasi Rencana',
            icon: 'fas fa-clipboard-check',
            onClick: this.realistPlan.bind(this)
          }
        },{
          name: 'sharePlanButton',
          location: 'after',
          widget: 'dxButton',
          options: {
            hint: 'Realisasi Rencana',
            icon: 'fa fa-share-alt',
            onClick: this.sharePlan.bind(this)
          }
        });
      }