devextreme - 如何使用 jquery Devextreme 在 cellTemplate 中格式化数字?
问题描述
我想自定义我的借方和贷方列。当有数量时,它会变成blue color
,当点击它时,它会show pop up
。如果是amount is zero
那么它将是blank
。问题是当我使用 cellTemplate 自定义单元格时,customText 和格式不起作用。有人对此有想法吗?请看我的JS Fiddle
起初,通过使用它,我能够使零值变为空白(见借方列)
{
dataField: "debit",
caption: "DEBIT",
dataType: "number",
width: 150,
format: "#,##0.00;(#,##0.00)",
customizeText: function(cellInfo) {
if (cellInfo.valueText === "0.00") {
return " ";
} else {
return cellInfo.valueText;
}
},
}
添加 cellTemplate 后,customText 和格式不起作用。金额格式不正确,零也没有变成空白。(见学分栏)
{
dataField: "credit",
caption: "CREDIT",
dataType: "number",
width: 150,
format: "#,##0.00;(#,##0.00)",
customizeText: function(cellInfo) {
if (cellInfo.valueText === "0.00") {
return " ";
} else {
return cellInfo.valueText;
}
},
cellTemplate: function(container, cellInfo) {
var credit = cellInfo.data.credit;
if (credit !== "0.0000") {
var color1 = "blue"
}
$('<a/>').addClass('dx-link')
.text(cellInfo.data.credit)
.css("color", color1)
.on('dxclick', function() {
$("#popup").dxPopup("instance").show();
$("#txt").dxTextArea("instance").option("value", cellInfo.data.credit);
})
.appendTo(container);
}
}
我当前的输出
解决方案
当你使用cellTemplate
andformat
时customizeText
被忽略。使用时,cellTemplate
您必须手动格式化值。
推荐阅读
- node.js - socket.io 真的会压缩有效载荷吗?
- postgresql - 更改 PostgreSQL 日志目录
- java - 任务:app:mergeExtDexDebug在运行反应本机的android应用程序中失败
- spring - 清理数据库时 Flyway 卡住(Postgres 11)
- c++ - 读取文件 C++ 时出现奇怪的错误
- mysql - 显示查询 mysql 条件
- python - 如何在 Fasttext 监督分类模型中为每个标签获取最重要的标记?
- c# - 我的 IntelliSense 没有显示任何自动填充,即使代码仍然有效
- windows - SetWindowPos 如何影响所有者窗口的 Z 顺序?
- javascript - 如果 array2 不具有相同的对象键值,则从对象数组 (array1) 中删除对象