EasyUI Forum
March 28, 2024, 04:23:10 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Set class to only one cell in a datagrid  (Read 8574 times)
jega
Full Member
***
Posts: 190


View Profile
« on: November 29, 2016, 03:24:47 AM »

Hi.

Have tried the last 4 hours to find a solution.

I'm having a datagrid with some columns and some rows. Col name 1 is "availableStatus", col name 2 is userName

In a script, i get a status on a user, runs through the datagrid's data and find row number where user match col userName.

So far so good.

Now i want to change the cell class, depending on the available status (background red, green, yellow)

How can i add this class to the cell ??

Logged
jarry
Administrator
Hero Member
*****
Posts: 2260


View Profile Email
« Reply #1 on: November 29, 2016, 08:06:37 AM »

You can define the column's 'styler' function to custom the cell style. Please look at this example:
http://www.jeasyui.com/demo/main/index.php?plugin=DataGrid&theme=default&dir=ltr&pitem=DataGrid%20Cell%20Style
Logged
jega
Full Member
***
Posts: 190


View Profile
« Reply #2 on: November 29, 2016, 08:31:16 AM »

Hi Jarry

Yes i know. I have used it to style an cell when loading data to the grid. This time i need to apply a class to a specific cell where already loaded data. It's a list of persons, with a cell for available status. Data is fetched by an api that tell me if the user is on/offline. Depending on status, i need to change the background color of cell to red/green.


regards Jesper
Logged
jarry
Administrator
Hero Member
*****
Posts: 2260


View Profile Email
« Reply #3 on: November 29, 2016, 03:15:03 PM »

After defining the styler to return the CSS class, you should call refreshRow or updateRow methods to apply the new cell style.
Logged
zolotoy
Jr. Member
**
Posts: 89


View Profile Email
« Reply #4 on: June 21, 2018, 08:43:26 AM »

So, how exactly to change an html of the specific cell at the run time?
Logged
jarry
Administrator
Hero Member
*****
Posts: 2260


View Profile Email
« Reply #5 on: June 21, 2018, 05:59:59 PM »

To change the cell's html, you should change the row data and refresh this row. Try to call 'refreshRow' or 'updateRow' methods.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!