ng-matero / extensions

Angular Material Extensions Library.
https://ng-matero.github.io/extensions/
MIT License
393 stars 48 forks source link

Disabled button in mtx-grid #26

Closed Huuvinh94 closed 2 years ago

Huuvinh94 commented 3 years ago

I have column with file option and type button, as shown below:

image

How to disabled button?

Please help me? Thanks a lot.

nzbin commented 3 years ago

It doesn't support disabled button in column config yet, you can customize buttons with cellTemplate

Luperco commented 3 years ago

It doesn't support disabled button in column config yet, you can customize buttons with cellTemplate

Unfortunately it is static. Cannot disable if an external event (for example after got data from server) tell me that should be disabled.

Any other suggestions?

Thanks.

nzbin commented 3 years ago

It doesn't support disabled button in column config yet, you can customize buttons with cellTemplate

Unfortunately it is static. Cannot disable if an external event (for example after got data from server) tell me that should be disabled.

Any other suggestions?

Thanks.

<mtx-grid [data]="list"
          [columns]="columns"
          [cellTemplate]="{operation: operationTpl}">
</mtx-grid>

<ng-template #operationTpl let-row let-index="index" let-col="colDef">
  <button [disabled]="disabled_condition">{{row}}</button>
</ng-template>
Luperco commented 3 years ago

Thank you, I'll give it a try.

Luperco commented 3 years ago

I use the icon, pop and popTitle feature of the command column, like this:

  tableButtons: MtxGridColumn = {

    header: 'Operation',
    field: 'operation',
    width: '160px',
    pinned: 'right',
    right: '0px',
    type: 'button',
    buttons: [
      {
        type: 'icon',
        text: 'delete',
        icon: 'attach_file',
        click: record => this.openFileUploader(record),
      },
      {
        type: 'icon',
        text: 'edit',
        icon: 'edit',
        click: record => this.edit(record),
      },
      {
        type: 'icon',
        text: 'delete',
        icon: 'delete',
        color: 'warn',
        pop: true,
        popTitle: 'Confirm delete?',
        click: record => this.delete(record),
      },
    ],
  };

Is there a way to replicate with cellTemplate?

Thanks.

Luperco commented 3 years ago

Nevermind. I was able to figure by myself. I had to write my popup confirmation (with MtxDialog.confirm()) and use mat-button-icon for icons. Thank you anyway.

ismailix commented 2 months ago

buttons: [ { type: 'icon', icon: 'edit', tooltip: this.translate.stream('organizations.edit'), click: record => this.edit(record), },

edit(value: any) { const dialogRef = this.dialog.originalOpen(LicencesEditComponent, { width: '600px', data: { record: value }, });

dialogRef.afterClosed().subscribe(() => console.log('The dialog was closed'));

}

how can I disable them and open ORGANIZATIONEDITCOMPONENT

nzbin commented 2 months ago

@ismailix You mean disable the button? https://ng-matero.github.io/extensions/components/grid/overview#row-with-buttons

ismailix commented 2 months ago

@nzbin when I click on this button, it should not open in the dialog window, but instead I want a new window to open