我想隐藏“编辑和删除”命令列,而只显示“添加新行”选项,以便网格中没有数据

时间:2019-06-12 08:34:21

标签: angular

                                            添加新行                                                                                               编辑                                               {{ 是新的 ? '添加':'更新'}}               

          <button kendoGridRemoveCommand class="k-primary" tabindex="26">
            Delete
          </button>
          <br /><br />
          <button kendoGridCancelCommand class="k-primary" (click)="onCancel()" tabindex="27">{{ isNew ? 'Cancel' : 'Cancel' }}</button>
        </ng-template>
      </kendo-grid-command-column>

1 个答案:

答案 0 :(得分:0)

您可以使用NgIf指令,如下所示:

<div *ngIf="dataInTheGrid; then thenBlock else elseBlock"></div>
<ng-template #thenBlock>Content to render when condition is true.</ng-template>
<ng-template #elseBlock>Content to render when condition is false.</ng-template>

有类似的东西

<div *ngIf="dataInTheGrid; then thenBlock else elseBlock"></div>

<ng-template #thenBlock>
  <kendo-grid-command-column>
    <button kendoGridRemoveCommand class="k-primary" tabindex="26">Delete</button>
    <br /><br />
    <button kendoGridCancelCommand class="k-primary" (click)="onCancel()" tabindex="27">Update</button>
  </kendo-grid-command-column>
</ng-template>

<ng-template #elseBlock>
  <kendo-grid-command-column>
    <button kendoGridCancelCommand class="k-primary" (click)="onCancel()"
      tabindex="27">Add new Row</button>
  </kendo-grid-command-column>
</ng-template>