|
|
#1 |
|
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 511
Karma: 65460
Join Date: Jun 2011
Device: Kindle
|
Color coding and designing composite columns
I have three custom columns that are Yes/No columns (let's call them "#cola", "#colb", and "#colc"). I would like to create a fourth column that displays 8 values, ideally with each text value as its own color (as in a "Text, but with a fixed set of permitted values" column):
"ColA" (if only #cola's value is "Yes"), "ColA, ColB" (if only #cola and #colb values are "Yes"), "ColA, ColB, ColC" (if all three columns have "Yes" values), "ColA, ColC" (if only #cola and #colc values are "Yes"), "ColB, ColC" (if only #colb and #colc values are "Yes"), "ColB" (if only #colb's value is "Yes"), "ColC" (if only #colc's value is "Yes"), and finally simply blank (if all values are either "No" or "Blank") Anyone know how this would be possible, and what the syntax would be? |
|
|
|
|
|
#2 |
|
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 22,036
Karma: 30277960
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
@ElMiko - should be possible create the with a column built from other columns using a program mode template, see ==>> The calibre template language — Advanced features
I think you could that colour than column according to its value - not certain on that as I don't colour columns. BR Last edited by BetterRed; 01-03-2015 at 09:26 PM. |
|
|
|
| Advert | |
|
|
|
|
#3 |
|
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 511
Karma: 65460
Join Date: Jun 2011
Device: Kindle
|
@BR-thanks for the quick reply. I had already looked at the tutorial for custom column syntax, but couldn't make heads or tails of it (I'm assuming it's some variation on the "contains" syntax). I was rather hoping that one of the gurus here would be able to get me started...
|
|
|
|
|
|
#4 | |
|
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 22,036
Karma: 30277960
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Quote:
![]() Have a look in these two threads while you're waiting for the Masters of the Templates to report for duty ![]() Custom Column Recommendations Plugboard, template, and custom composite column recipes I have a suspicion I saw something in one of them that were along the lines of what your after. BR |
|
|
|
|
|
|
#5 |
|
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Code:
program:
part1=contains(field('#cola'), 'Yes', 'colA', '');
part2=contains(field('#colb'), 'Yes', 'colB', '');
part3=contains(field('#colc'), 'Yes', 'colC', '');
final=list_union(
'',
strcat(part1, ',', part2, ',', part3)
','
);
I've never really played around with custom columns, but you can set 8 rules to match each state with a different color. I think you have to have a rule per color. Edit: Right, like chaley said, templates are "hiding" at the bottom.
Last edited by eschwartz; 01-04-2015 at 04:08 AM. |
|
|
|
| Advert | |
|
|
|
|
#6 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,528
Karma: 8065948
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
For the column contents, the following general program mode template should work:
Code:
program:
list_union(
'',
strcat(
contains(field('#cola'), 'yes', 'ColA,', ''),
contains(field('#colb'), 'yes', 'ColB,', ''),
contains(field('#colc'), 'yes', 'ColC,', ''),
), ',')
Code:
program:
v = field('#composite');
first_non_empty(
strcmp(v, '', '', 'azure', ''),
strcmp(v, 'cola', '', 'orange', ''),
strcmp(v, 'colb', '', 'red', ''),
strcmp(v, 'colc', '', 'blue', ''),
strcmp(v, 'cola, colb', '', 'yellow', ''),
strcmp(v, 'cola, colc', '', 'pink', ''),
strcmp(v, 'colb, colc', '', 'mauve', ''),
strcmp(v, 'cola, colb, colc', '', '#445533', ''),
)
|
|
|
|
|
|
#7 |
|
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
chaley, the first template produces "colAcolBcolC"...
add ',', to the end of the first two lines inside strcat. I stole your idea of strcat'ing inside the list_union and edited my post above. Last edited by eschwartz; 01-04-2015 at 04:10 AM. |
|
|
|
|
|
#8 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,528
Karma: 8065948
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
|
|
|
|
|
|
#9 |
|
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 511
Karma: 65460
Join Date: Jun 2011
Device: Kindle
|
I'm embarrassed to admit it, but it looks like I'm in way over my head. I really appreciate all your input, but I don't know where I am adding these programs or how I am referring to them within the custom column. And that's just for starters!
@chaley: with the commas inside the display value, does that mean that if only #cola was positive, the displayed value would be "ColA,"? |
|
|
|
|
|
#10 | ||
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,528
Karma: 8065948
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
My second template goes into an advanced coloring rule. Quote:
|
||
|
|
|
|
|
#11 |
|
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
So they are.
Didn't notice it because it was hidden in the return value for contains. I put them in separate strings to strcat, I guess it just makes it easier for me to visualize.Is it strictly necessary for this to be a behaves-like-tags custom template column? |
|
|
|
|
|
#12 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,528
Karma: 8065948
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
No, but I think using behaves-like-tags makes the column more useful in the tag browser and (if used) calibre companion. After all, it is in fact a list of values, which is what "like tags" is designed for.
|
|
|
|
|
|
#13 |
|
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 511
Karma: 65460
Join Date: Jun 2011
Device: Kindle
|
@chaley & eschwartz — Thank you both for all your help! You were tremendously helpful. Frankly, I had hoped (and tried) to figure this out on my own, but soon relaized that I was boxing outside my weightclass. Thanks again!
|
|
|
|
![]() |
| Tags |
| custom column |
| Thread Tools | Search this Thread |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Color Columns shows 2 'Formats' | phossler | Calibre | 2 | 10-22-2014 11:22 AM |
| Composite column problem combining two tag type columns | At_Libitum | Recipes | 1 | 08-29-2013 01:31 PM |
| Designing for Kobo | AlexBell | ePub | 45 | 01-21-2013 02:09 AM |
| composite custom columns sorted numerically | Doug-W | Library Management | 2 | 02-18-2011 03:16 AM |
| Coding headings in color | Alda | ePub | 11 | 01-27-2011 08:57 AM |