美文网首页
bootstrapTable根据条件隐藏一列的办法

bootstrapTable根据条件隐藏一列的办法

作者: 李北北 | 来源:发表于2017-09-10 18:35 被阅读0次

    $(function() {
    $('#dataGrid').bootstrapTable(
    {
    url : 'article/selectListByType',
    method : 'post',
    toolbar : '#toolbar',
    contentType : 'application/x-www-form-urlencoded',
    striped : true,
    showColumns : true,
    showRefresh : true,
    pagination : true,
    pageSize : 10,
    sortName : 'id',
    sidePagination : 'server',
    queryParamsType: 'limit',
    queryParams: queryParams,
    columns : [
    /* {checkbox : true}, */
    {
    field : 'id',
    title : '',
    align : 'center',
    formatter : function(value, row, index) {
    return index + 1;
    }
    },
    {field : 'lastModTime',title : '发布时间', width: 150},
    {field : 'noticeType',title : '公告类型',align : 'center', formatter:function(value, row, index){
    var noticeTypeJson = {
    1:"物业公告",
    2:"管委会公告",
    3:"园区风采"
    };
    return noticeTypeJson[row.noticeType || 4] || "未知类型";
    }}
    ]
    });
    if($('#type').val() != 1){
    $('#dataGrid').bootstrapTable('hideColumn', 'noticeType');
    }
    });

    如上代码,可根据需要将公告类型列隐藏起来。

    if($('#type').val() != 1){
            $('#dataGrid').bootstrapTable('hideColumn', 'noticeType');
        }

    相关文章

      网友评论

          本文标题:bootstrapTable根据条件隐藏一列的办法

          本文链接:https://www.haomeiwen.com/subject/qcjtsxtx.html