【问题标题】:How to customize display format in jquery jtable如何在jquery jtable中自定义显示格式
【发布时间】:2016-02-17 10:32:48
【问题描述】:

我的数据库中有一个状态数据字段,我需要我的 jquery jtable 上的这些数据以不同的格式显示,例如,如果数据为 1,则显示红色按钮,如果数据为 0,则显示绿色按钮。我怎样才能在 jquery jtable 中做到这一点?

【问题讨论】:

标签: jquery jquery-jtable


【解决方案1】:
publish: {
                    title: '',
                    width: '0.65%',
                    list: true,
                    sorting:false,
                    type: 'radiobutton',
                    options: { '1': 'Publish', '0': 'Unpublish' },
                    display: function (data) {
                        //alert(data.record.publish);
                        if(data.record.publish == '1'){
                            return '<button id="un" style = "width:90px; max-width:90px; text-align:center;" class="btn btn-danger" title="Unpublish Post" type="button" onclick="changeStatus('+data.record.OID+');">Unpublish</button>';
                        }
                        else {
                            return '<button id="pub" style= "max-width:90px; width:90px; text-align:center;" class="btn btn-success" title="Publish Post" type="button" onclick="changeStatus('+data.record.OID+');">Publish</button>';
                        }
                    }
      }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多