首页 > 解决方案 > 在 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);
                        }
                    }
                },
            ]
        });

标签: jqueryjquery-uigridjqxgrid

解决方案


推荐阅读