簡體   English   中英

如何在kendo網格中編寫IF條件?

[英]How to write IF condition in kendo grid?

我想在kendo網格列中使用if條件。 但它不起作用。 我想把圖像視情況而定。 有語法錯誤嗎?

<kendo-grid-column field ="Scanned_STS" title="Status" width="20">
  <ng-template kendoGridCellTemplate let-dataItem> "# if(Scanned_STS == 1) { #  #= "<img src=''>" # # } else if (Scanned_STS == 0) { # #= "<img src=''>" # # }"</ng-template>
</kendo-grid-column>

嗨如果你使用角度你可以使用NgIf

import { Component } from '@angular/core';
import { sampleProducts } from './products';

@Component({
    selector: 'my-app',
    template: `
         <kendo-grid [data]="gridData">
            <kendo-grid-column field="ProductName">
                <ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
                    <strong>{{dataItem.ProductName}}</strong>
                      <img *ngIf='dataItem.Discontinued' src='' alt='Item Discontinued'/>
                      <img *ngIf='!dataItem.Discontinued' src='' alt='Item Continued'/>
                </ng-template>
            </kendo-grid-column>
        </kendo-grid>
    `
})
export class AppComponent {
    public gridData: any[] = sampleProducts;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM