【问题标题】:Define Cell style for Jquery-Jtable为 Jquery-Jtable 定义单元格样式
【发布时间】:2013-09-19 05:15:22
【问题描述】:

jquery-Jtable 的结果返回给客户端后,在表标签处生成我们需要的字段,但我想为表的最后一列或 Jquery Jtable 选项中的最后一个字段定义 css, 我的意思是“状态”列有背景:

if status==1 bgcolor:red , 

if status==2 bgcolor:green ,

if status==3 bgcolor:yellow ,

所以我写了这段代码:

fields: {
    Status: {
        title: 'RequestStatus',
        width: '4%',
        display: function( data ) {
            ???
        }
    }
}

【问题讨论】:

  • 你能更清楚你想要什么吗?
  • 我编辑了这个。请检查一下

标签: jquery css jquery-jtable


【解决方案1】:

根据 jTable API 参考,看起来listClass 可能是您为单个表格单元格样式化而寻找的。​​p>

listClass, 细绳, 默认:无

一个字符串值,可以设置为表格中此字段(td 元素)的单元格的类/类。因此,您可以对表格中的字段进行样式化。

http://www.jtable.org/ApiReference#fopt-listClass

【讨论】:

  • 在这种情况下,td 列将向右,但标题将保持在左侧,因为它是.. 有什么方法可以向右移动标题?
【解决方案2】:

这是一种使用条件逻辑允许在单元格上自定义样式的方法:在 jTable 中为每一行和字段(单元格)使用显示选项,下面的代码示例演示了我的意思:

      <style> 
       .redCell
        {
        } 
      </style>

           //---attribute for J table fields   

       display : function(data){
                     if(data.record.status=="1" return "<div class='redCell'>" + data.record.StatusTitle +"</div>";
                     if ... 
                        ... 
                    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-06-26
    • 1970-01-01
    • 2013-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-09
    相关资源
    最近更新 更多