_cfv - help #404
-
Hi I'm wanting to highlight a menu button if a criteria is met. In this case I'd like to highlight the "Archived Notes" button in some way if the field "Has Archived Notes" is Yes. How do I target the correct menu button for the _cfv=[.....] statement? I believe the conditional statement will be [ktlCond, is, Yes, Has Archived Notes]. Once this is working then I'd hide the "Has Archived Notes" field. Dean |
Beta Was this translation helpful? Give feedback.
Replies: 23 comments 4 replies
-
Hi Dean Try this '_cfv=[Has Archived Notes, is, Yes, fontColor, backgroundColor], [ktlTarget, $('#view_123 li.contains("Archived Notes")')]` Replace fontColor & backgroundColor with your colors & 123 with the view id of the menu view. Let us know how it goes. |
Beta Was this translation helpful? Give feedback.
-
Hi Craig Thank you for offering a solution. I tried the following unsuccessfully: '_cfv=[Has Archived Notes, is, Yes, black, red, bold,], [ktlTarget, $('#view_347 li.contains("Archived Notes")')]' I broke it down to this '_cfv=[Has Archived Notes, is, Yes, black, red, bold,]' which shows the _cfv is working so the issue is targeting the menu button. Do you have any other thoughts? Dean |
Beta Was this translation helpful? Give feedback.
-
Try a:contains some versions of knack are different
Craig
…On Tue, 5 Nov 2024, 21:55 Deanobeano2, ***@***.***> wrote:
Hi Craig
Thank you for offering a solution.
I tried the following unsuccessfully:
'_cfv=[Has Archived Notes, is, Yes, black, red], [ktlTarget, $('#view_347
li.contains("Archived Notes")')]'
'_cfv=[Has Archived Notes, is, Yes, black, red, bold,], [ktlTarget,
$('#view_347 li.contains("Archived Notes")')]'
I broke it down to this '_cfv=[Has Archived Notes, is, Yes, black, red,
bold,]' which shows the _cfv is working so the issue is targeting the menu
button.
image.png (view on web)
<https://github.com/user-attachments/assets/389db8bb-ab95-4417-b538-f218c4dc356f>
Do you have any other thoughts?
Dean
—
Reply to this email directly, view it on GitHub
<#404 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACQQXAYFH2KIYNSC2TU5GGDZ7E5FTAVCNFSM6AAAAABRFEZIMGVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCMJVHE4DOMA>
.
You are receiving this because you commented.Message ID:
<cortexrd/Knack-Toolkit-Library/repo-discussions/404/comments/11159870@
github.com>
|
Beta Was this translation helpful? Give feedback.
-
Hi Craig The braincells started working and I finally found where Norm had helped me with a similar issue. I removed the archive icon and used this which resulted in the desired result, for the meantime: '_cfv=[Has Archived Notes, is, Yes, black, red, bold,], [ktlTarget, $('#view_347 .knMenuLink:textEquals("Archived Notes")')] Do you know if it's possible to add the archive icon back in and still achieve this result? Dean |
Beta Was this translation helpful? Give feedback.
-
Hi @Deanobeano2, I was just about to ask you to try the textEquals syntax. ND |
Beta Was this translation helpful? Give feedback.
-
It's ok, I found that page. |
Beta Was this translation helpful? Give feedback.
-
Dean, It seems that there is no icon in the first place! Even when I bypass the KTL, there's nothing. See it here: Norm |
Beta Was this translation helpful? Give feedback.
-
Hi Norm Sorry, you're too fast for me. There's no bug. I removed the icon to eliminate variables and make it easier to copy the code you'd supplied previously. What I'd now like to do, if possible, is add the icon back but assume that will mean changing the criteria from "textEquals" to something else. What would that be? Dean |
Beta Was this translation helpful? Give feedback.
-
I see what you mean.
There's a bug and I'll fix it. |
Beta Was this translation helpful? Give feedback.
-
Hi Norm It stops working when the Archive icon is re-introduced, sorry. Dean |
Beta Was this translation helpful? Give feedback.
-
I got it. Try Dev version in 10 seconds. |
Beta Was this translation helpful? Give feedback.
-
Can you put back the icon? |
Beta Was this translation helpful? Give feedback.
-
The icon is back. To run the Dev version do I select KTL Code and then enter Dev? |
Beta Was this translation helpful? Give feedback.
-
If so, I see a flash of, the now, orange background before it finally renders with none of the desired formatting. |
Beta Was this translation helpful? Give feedback.
-
This is becoming crazy and hard to debug!!!! Sometimes you add the icon with the text (top arrow), then the next line you add the icon in the menu (bottom arrow). So, the reason why it didn't work in the first place is because the icon is part of the text. If you add the icon with the text, the code will work properly, but only if you add the same icon in your comparison string in the _cfv keyword. Both must match. Otherwise, add the icon with the menu button and it will also work. On my side, I'll leave the code as it was. |
Beta Was this translation helpful? Give feedback.
-
Go back to Prod version, forget about Dev for now. |
Beta Was this translation helpful? Give feedback.
-
Sorry, I've always just used the Knack standard default for adding an icon. |
Beta Was this translation helpful? Give feedback.
-
Ok, but about the other one to the left: Jobs. I suspect that the icon is part of the text like this: "🧹Jobs", and not a separate icon like you've shown here. |
Beta Was this translation helpful? Give feedback.
-
Sorry, it's all working now. I'd left some in some Javascript that was interfering with KTL. |
Beta Was this translation helpful? Give feedback.
-
Ok then, maybe this was part of the issue. But still, you must remember that if you include some icon in your label, you must also include that same icon in the condition for a keyword. If all good, mark this post as the Anwser so it closes please. Cheers, |
Beta Was this translation helpful? Give feedback.
-
How would you specify the icon in the condition for the keyword in this case? |
Beta Was this translation helpful? Give feedback.
-
It would be like this: _cfv=[Has Archived Notes, is, Yes, black, #ffbb73, bold,], [ktlTarget, $('#view_347 .knMenuLink:textEquals("📦Archived Notes")')] Assuming the label of your button would also be "📦Archived Notes". Then, all your icons (emojis in this case) would have the same style, with colors. As Craig pointed out, you can also use :contains instead of :textEquals. This would be more permissive and find the text successfully because it doesn't require to be an exact match, ignoring the icon. But then it might select the wrong element if you had another one like "📦Un-Archived Notes", for example. |
Beta Was this translation helpful? Give feedback.
-
Hi Norm Thank you for the tip on how to inspect the elements as I never knew you could do it that way. Dean |
Beta Was this translation helpful? Give feedback.
Sorry, I've always just used the Knack standard default for adding an icon.