gpt4 book ai didi

javascript - KendoUI 列模板中的条件未按预期工作

转载 作者:行者123 更新时间:2023-11-30 20:12:27 26 4
gpt4 key购买 nike

我通过 API 获取 JSON 数据并使用 Kendo UI 将其显示在表格中。

$scope.ReportViewGrid = function ReportViewGrid(jsonData) {
if (jsonData == null) return;

var fileName = "ReportView";
var grid = $("#ReportViewGrid").kendoGrid({
toolbar: [{
template: "<input type='button' class='k-button' value='Back' onclick='back()' />"
}],
editable: false,
filterable: true,
resizable: true,
pageable: {
pageSize: 10,
buttonCount: 5
},
columns: jsonData.columns,
dataSource: {
data: jsonData.children
},

}).data("kendoGrid");
}
<div id="ReportViewGrid"></div>


上面的代码完美地显示了数据。网格中有多个列如下:

-----------------C1 | C2 | C3 | C4-----------------v1 | v2 | v3 | v4x1 | x2 | x3 |y1 | y2 | y3 |z1 | z2 | z3 | z4

Column1 is made linked using template. But I want to get linked data where I'm having value in column4 otherwise normal text. I've tried the following code and tried flipping the condition as well but the links are always coming up.

...
if("uName".equalsIgnoreCase(uNameField)){
template = "# if (\"#=encodeURI(md5hash)#\".equals(\"\") ) { #"
+" <span>#=fileName#</span>"
+" # } else{ #"
+" <a style=\"cursor: pointer;\" onclick='expand(\"fileDetailForDuplicateFile\",\"#=encodeURI(fileName)#\",\"#=encodeURI(md5hash)#\")'>#=fileName#</a>"
+" #} #";
nodeColumns.setTemplate(template);
}
root.addColumns(nodeColumns);
}
root.addLinkedColumn("uName");
Gson gson = new Gson();
return gson.toJson(root);


有什么我想念的吗?任何帮助都会很棒。

最佳答案

我发现这对于使用 data.xx 在模板内部进行检查非常有用,如下所示:-

template = "# if(data.md5hash == ''){ #" +
" <span>#=fileName#</span> " +
" #} else {#" +
" <a style=\"cursor: pointer;\" onclick='expand(\"fileDetailForDuplicateFile\",\"#=encodeURI(fileName)#\",\"#=encodeURI(md5hash)#\")'>#=fileName#</a>" +
" # } #";

关于javascript - KendoUI 列模板中的条件未按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52258271/

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