Login | Register 
FEATURES
APPLICATIONS
DOWNLOADS
EDUCATION
BLOG
WIKI
FORUM
STORE

List Widget - Specific Row Color and Custom TOP per Cell

Still a little green? Ask your beginner's questions here

List Widget - Specific Row Color and Custom TOP per Cell

Postby carloalan » Wed Jun 12, 2019 9:17 am

Hey There,

Im using the current List Widget and I would like to know how to set a color per row and a specific TOP per cell.

More concrete:
In my List I have a cell per row called 'Active' and in the cell is either a 0 or a 1. I would like to have the rows with 'Active' = 0 have a red background color. Additionally instead of having 0 and 1 displayed I would like to choose a TOP accordingly -> Happy Smiley, Not Happy Smiley.

Im checking inside the List colDefine on the wiki but somehow I cant get it off the ground. Any pointers?
Attached is a excerpt of my list showing whats happening.
Attachments
customlist.tox
(38.38 KiB) Downloaded 34 times
carloalan
 
Posts: 17
Joined: Wed Jul 27, 2011 1:10 pm

Re: List Widget - Specific Row Color and Custom TOP per Cell

Postby bLackburst » Mon Jul 08, 2019 9:09 pm

+1 The list/er widget is confusing as hell.
bLackburst
 
Posts: 334
Joined: Thu Sep 01, 2011 3:56 am
Location: Melbourne, Australia

Re: List Widget - Specific Row Color and Custom TOP per Cell

Postby Ivan » Wed Jul 10, 2019 2:30 pm

The list widget (based on https://docs.derivative.ca/Palette:lister) has a bit of a learning curve, but is extremely powerful.

To set a specific TOP depending on data, use a * in the colDefine topPath column (docs: https://docs.derivative.ca/Palette:list ... fine_table)

To set a specific color depending on data, you have to use callbacks and there are multiple ways. I recommend this: set the column's "sourceDataMode" to "color". Then, in the onConvertData callback, do something like this:
Code: Select all
def onConvertData(info):
   for row in info['data']:
      colorCol = 3
      if row[colorCol] == '0':
         row[colorCol] = [0,0,0,255]
      else:
         row[colorCol] = [255,0,0,255]

This makes it so whenever the list's data is refreshed, the column's 1 or 0 is converted to a color.
User avatar
Ivan
Staff
 
Posts: 233
Joined: Fri Mar 18, 2016 7:12 pm


Return to Beginners

Who is online

Users browsing this forum: No registered users and 7 guests