Cell style definition for jQuery-Jtable

After returning the jquery-Jtable result to the client, create the necessary fields in the table tag, but I want to define css for the last column of the table or my last field in the JQuery Jtable parameters. I mean the "status" column has a background that:

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 ) { ??? } } } 
+4
source share
2 answers

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

listClass , string, default: none

A string value that can be set as the class / classes of the cell of this field (td element) in the table. This way you can style the fields in the table.

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

+5
source

Here is a way to enable custom styles on cells using conditional logic: use the display parameter 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 ... ... } 
+5
source

Source: https://habr.com/ru/post/1502952/


All Articles