亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

KendoUI 列模板中的條件未按預期工作

KendoUI 列模板中的條件未按預期工作

一只斗牛犬 2021-09-12 15:43:43
我通過 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 | z4Column1 使用模板進行鏈接。但我想獲取鏈接數據,其中我在 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);有什么我想念的嗎?任何幫助都會很棒。
查看完整描述

1 回答

?
小唯快跑啊

TA貢獻1863條經驗 獲得超2個贊

我發現這對于使用 data.xx 在模板內部進行檢查很有用,如下所示:-


template = "# if(data.md5hash == ''){ #" +

" <span>#=fileName#</span> " +

" #} else {#" +

" <a style=\"cursor: pointer;\" onclick='expand(\"fileDetailForDuplicateFile\",\"#=encodeURI(fileName)#\",\"#=encodeURI(md5hash)#\")'>#=fileName#</a>" +

" # } #";


查看完整回答
反對 回復 2021-09-12
  • 1 回答
  • 0 關注
  • 142 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號