Question

After return result of jquery-Jtable to client, Generate our needed fields at table tag , but i want to define css for last column of table or last my field in Jquery Jtable options, I mean The "status" column have background which :

if status==1 bgcolor:red , 

if status==2 bgcolor:green ,

if status==3 bgcolor:yellow ,

so I wrote this code :

fields: {
    Status: {
        title: 'RequestStatus',
        width: '4%',
        display: function( data ) {
            ???
        }
    }
}
Était-ce utile?

La solution

According to the jTable API reference, it looks like listClass may be what you are looking for to stylize individual table cells.

listClass, string, default: none

A string value that can be set as class/classes of a cell of this field (td element) in the table. Thus, you can stylize fields in the table.

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

Autres conseils

Here is a way to allow custom styles on cells by using conditional logic: use the display option in jTable for each row and field(Cell), The following code example demonstrates what I mean:

      <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 ... 
                        ... 
                    }
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top