jquery - 在 jquery 网格的单元格中更改按钮文本(或显示隐藏按钮)
问题描述
我有一个 jquery 网格(Jqxgrid),我在最后一个单元格中添加了一个按钮 - 用于查看报告。我需要自定义此按钮或单元格,如果文件路径为空(文件路径是另一个单元格值),则视图报告按钮文本更改为恢复。或者,如果有任何方法可以隐藏查看报告按钮并显示恢复按钮。这在 jqxgrid 中是可能的还是我过度瞄准了?
参考代码:最后一列是按钮类型,我需要自定义。
// initialize jqxGrid
grid.jqxGrid({
width: "100%",
height: "100%",
source: dataAdapter,
showtoolbar: false,
selectionmode: 'none',
sortable: true,
altrows: true,
columnsresize: true,
filterable: true,
editable: true,
enabletooltips: true,
filtermode: 'excel',
rendertoolbar: function (toolbar) {
var me = this;
},
columns: [
{ text: "Queue Id", datafield: "ReportId", editable: false, width: "10%" },
{ text: "Who Updated", datafield: "WhoUpdated", editable: false, width: "20%" },
{ text: "Date Updated", datafield: "UpdatedOn", cellsalign: "left", editable: false, width: "20%" },
{
text: "Report", datafield: "ReportUrl", width: "10%", cellsalign: "left",
columntype: "button",
cellsrenderer: function () {
return "View Report";
// return '<img src="../Images/Download.png"/>';
},
buttonclick: function (row) {
var value = $('#jqxgrid').jqxGrid('getcellvalue', row, "ReportUrl");
if (value !== "") {
const url = $("#getReportDownloadUrl").val()
+ "?filePath=" + value.replace(/^"(.+(?="$))"$/, '$1') ;
produceReport(url);
}
}
},
]
});
解决方案
推荐阅读
- typescript - 如何在 TypeScript 中获取全局变量?
- javascript - 使用复选框将 URL 哈希添加到同位素组合过滤器
- javascript - 带千位分隔符的简单乘法计算器
- jsf - 如何从 xhtml 页面为 JSF 托管 bean 的成员设置值?
- r - 如何设置优化函数中参数的限制?
- rust - 是否可以扩展单个宏而不是整个文件?
- python - 为什么 pandas pd.plotting.autocorrelation_plot(x) 产生的值与通常的自相关计算不同?
- java - RandomAccessFile.write:EBADF(错误的文件描述符)
- python - 如何设计一个实验来比较 del 运算符在列表和字典上的性能?
- exception - 处理 Java8 流中的 CompressorException