我通过 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 | v4
x1 | x2 | x3 |
y1 | y2 | y3 |
z1 | z2 | z3 | z4
Column1 使用模板进行链接。但我想获取链接数据,其中我在 column4 中具有价值,否则为普通文本。我已经尝试了以下代码并尝试翻转条件,但链接总是出现。
...
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);
有什么我想念的吗?任何帮助都会很棒。
小唯快跑啊
相关分类