微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使 igx-grid 的第一行不可编辑

如何解决使 igx-grid 的第一行不可编辑

我有一个普通的 igx-grid,其中的行都是可编辑的。但是,第一行不应该是可编辑的。我该如何处理?另外,在下面的代码片段中,你能告诉我我在最后一栏中做错了什么吗?我只想在那里显示一个垃圾桶图标,但该单元格是空白的。

<igx-grid (dropped)="onDropAllowed($event)" (onRowDragStart)="onDragallowed($event)"
          [data]="data?.approvers"
          [height]="null" [rowDraggable]="true" igxDrop primaryKey="wwid">
    <igx-column [cellEditorTemplate]="workerPickerTemplate" [editable]="true" field="name" header="Name">
    </igx-column>
    <igx-column [cellEditorTemplate]="workerPickerTemplate" [editable]="true" field="email"
                header="Email"></igx-column>
    <igx-column [cellEditorTemplate]="workerPickerTemplate" [editable]="true" field="wwid" header="WWID">
    </igx-column>
    <igx-column [editable]="true" field="role" header="Role"></igx-column>
    <igx-column>
        <button class="btn btn-danger" igxButton="icon" type="button">
            <igx-icon>delete</igx-icon>
        </button>
    </igx-column>
</igx-grid>

解决方法

您可以使用 IgxGridComponentrowEditEnter 事件并取消它以防止进入编辑模式,从而有效地使其不可编辑。

关于在列中设置图标的问题,您应该将内容包装在这样的模板中:

    <igx-column width="100px" [filterable]="false">
       <ng-template igxCell let-cell="cell">
          <button igxButton="icon" (click)="removeRow(cell.cellID.rowIndex)">
              <igx-icon>delete</igx-icon>
          </button>
        </ng-template>
    </igx-column>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。