gpt4 book ai didi

javascript - Kendo UI && JavaScript - 显示 "YES"和 "NO"

转载 作者:行者123 更新时间:2023-11-30 11:10:19 25 4
gpt4 key购买 nike

我怎样才能做到这一点。我从我的数据库中获取了“y”和“n”数据。但在网格中我想显示“YES”和“NO”。需要显示在“segmentActive”栏中。

        $("#grid").kendoGrid({
dataSource: dataSource,
dataBound: onDataBound,
height:400,
sortable: true,

columns: [
{ field: "segmentActive", title:"STATUS", width: "50px", editor: RadioSegmentActive },
{ field: "marketSegmentName", title:"SEGMENT NAME", width: "180px" },
{ field: "publicPrice", title:"PUBLIC PRICE", width: "50px", editor: RadioPublicPrice },
{ field: "isHouseUse", title:"HOUSE USE", width: "50px", editor: RadioHouseUse},
{ command: ["edit"], title: " ", width: "30px" },
],
editable: "inline",
//....

另外,我还在编辑器中为单选按钮添加了另一个功能,用于添加和编辑目的。

function RadioSegmentActive(container, options) {
var guid = kendo.guid();

$('<input class="k-radio" id="radio3" name="segmentActive" type="radio" value="y" >').appendTo(container);
$('<label class="k-radio-label" for="radio3">YES</label>').appendTo(container); //YES
$('<br>').appendTo(container);
$('<input class="k-radio" id="radio4" name="segmentActive" type="radio" value="n" >').appendTo(container);
$('<label class="k-radio-label" for="radio4">NO</label>').appendTo(container); //NO
}

最佳答案

为此,您可以使用 template属性(property)。

它接受一个接收行数据的函数。将显示您返回的字符串。

ES6:

{ field: "segmentActive", ... template: data => data.segmentActive == "y" ? "YES" : "NO"  }

非 ES6:

function displaySegmentActive(data){
return data.segmentActive == "y" ? "YES" : "NO"
}

...

{ field: "segmentActive", ... template: displaySegmentActive }

关于javascript - Kendo UI && JavaScript - 显示 "YES"和 "NO",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53955493/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com