Using _cfv with ktlRefVal in a grid #185
-
Hi Norm, I want to compare 2 values, both in a grid view, and highlight one of the values if it's less than the other: If actual quantity is less than required quantity highlight actual quantity. I've tried using ktlRef value, with no success. I've tried many incarnations, here is one example (6499 is actual quantity, 6495 is required quantity)
I've run through the code and we end up here, with the refVal undefined:
Having re-read the _cfv Wiki it doesn't appear that comparing 2 values in a grid is supported, is this correct? Or am I missing something? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 20 comments 7 replies
-
Amanda, No this is not yet supported. But I'd really like to do it. I checked quickly and it's not going to be easy. I need to talk to Charles on how to implement this without breaking anything. I'll keep you posted, |
Beta Was this translation helpful? Give feedback.
-
Unless I missed something in Amanda post, it works for me. Maybe the extra "," in the first part is causing the issue for Amanda ??? Here is what I did: _cfv=[field_541,gt,ktlRefVal,#f70707,,], [ktlRefVal, field_540,] field 540 = "99" field 541 turns red, field 540 = "101" field 541 changes to green. If they both equal "100" there both black. I just can't get it to work for me if the fields have a currency values in them. |
Beta Was this translation helpful? Give feedback.
-
Amanda, I found a solution!!! And it's only 2 lines of code. It shouldn't disrupt anything. @jbk68: you don't include the last comma after field_540. This tells the KTL to find a view without a title or ID and derails the process. Norm |
Beta Was this translation helpful? Give feedback.
-
@jbk68 |
Beta Was this translation helpful? Give feedback.
-
Hey Norm, I went into DEV mode, and I couldn't get any of the below to work including your solution to the currency issue. I tried removing the comma after field_540 and I couldn't get that to work. Just a fyi, those fields 540 & 541 are just TEST short text fields. I logged out of DEV mode, tried it without the comma behind 540, didn't work. Put the comma back behind 540, the test fields will change colors accordingly. Please let me know what else to try. I'm trying to finish this project and would really like the ability to have the colors change with currencies. _cfv=[field_541,gt,ktlRefVal,#f70707,,], [ktlRefVal, field_540,] (short text fields) _cfv=[field_541,lt,ktlRefVal,#0bfd00,,], [ktlRefVal, field_540,] (short text fields) _cfv=[field_506,lt,ktlRefVal,#0bfd00,,], [ktlRefVal, field_472] (currency fields) Thanks again Norm... JON |
Beta Was this translation helpful? Give feedback.
-
I think I've got another fix for non-numeric fields. Norm |
Beta Was this translation helpful? Give feedback.
-
When I put the knack app in dev mode, what version should I be seeing? |
Beta Was this translation helpful? Give feedback.
-
You should see: v0.21.2-dev Follow the steps described here, to get in dev mode, but only on your device (without disturbing all other users): #186 (comment) Norm |
Beta Was this translation helpful? Give feedback.
-
I know how to switch to dev mode just wondering if when you switch it changed the version ( Still can't get anything to work in dev mode. Text and numeric work in normal only if I leave the comma after field_540. Nothing I've triedworks with a currency field. ??? |
Beta Was this translation helpful? Give feedback.
-
Hi Norm, Tried in dev, works for me until the refVal is 0:
Thanks Norm amazing work Amanda |
Beta Was this translation helpful? Give feedback.
-
Hey Amanda, yeah Norm is pretty amazing. Helped me up to midnight last night trying to figure out why I can't get it to work in dev mode. Question for you, do I have to assign myself any special roles (ie developer) to be able to see changes in dev mode? When I click current version in upper right corner, log in and turn on dev mode and see "0.21.2-dev" Is this all I need ?? Using KTL, I can get it to work perfectly in normal mode unless values include currencies, but nothing works in dev mode. _cfv=[field_541,gt,ktlRefVal,#f70707,,], [ktlRefVal, field_540,] ** ONLY WORKS WITH COMMA AFTER field_540 ??? ** _cfv=[field_541,lt,ktlRefVal,#0bfd00,,], [ktlRefVal, field_540,] ** ONLY WORKS WITH COMMA AFTER field_540 ??? ** I finally got the currency to work but had to use a java script to make it work, sure would be a lot easier to use KTL (see below): $(document).on('knack-view-render.view_262', function(event, view, data) {
|
Beta Was this translation helpful? Give feedback.
-
Jon, Your use case is somewhat special and can't be debugged by using only explanations and guessing. I really need to single-step in the code and examine variable's content, field types, field format, etc., to pinpoint the issue, all this in real-time, in the real application. The only way to do this is for you to create a temporary debug page for me to log-in and see dummy data that replicates the issue. I only need one grid, one row and two fields. It takes about two minutes to do this. Norm |
Beta Was this translation helpful? Give feedback.
-
Thanks Jon for giving me a debug page. I’ve checked your _cfv keyword and as I expected, the fact that you have an extra comma at the end of [ktlRefVal, field_id,] tells the KTL to use the view “” (empty string). So it fails and causes the rest of the code to generate undefined results. I’ve added some protection against empty parameters like this, so it shouldn’t happen again. And if it does, an error log will be generated in the console, and the code will exit to prevent false results. I'd ask you to remove all those commas from the view please, so I can resume debugging. Thanks, |
Beta Was this translation helpful? Give feedback.
-
I managed to simulate the _cfv I needed locally. So I think I've got a solution that works with all field types, including currencies. Please try the dev version and let me know if all looks good. Norm |
Beta Was this translation helpful? Give feedback.
-
All extra commas have been removed from the end. |
Beta Was this translation helpful? Give feedback.
-
In dev mode (debug this device) ... does it work? |
Beta Was this translation helpful? Give feedback.
-
Sweet... Using dev mode on the debug page I shared with you, the currency fields are now changing colors as expected. Hoping you implement it soon. Thanks for helping me with this issue... JON |
Beta Was this translation helpful? Give feedback.
-
Do a Ctrl+F5 just in case. |
Beta Was this translation helpful? Give feedback.
-
Norm, I just tried dev mode in one of my main apps and added a couple test currency fields to one of the tables and it works as expected in this app. Thanks again and please let me know when you implement it for normal use... JON |
Beta Was this translation helpful? Give feedback.
-
Done! The fix has been released in v0.22.2 If you remove the dev mode, you should see the same fix be applied. Thanks for both of you for reporting this :) Norm |
Beta Was this translation helpful? Give feedback.
Done! The fix has been released in v0.22.2
If you remove the dev mode, you should see the same fix be applied.
Mark as Answer please if it does the job.
Thanks for both of you for reporting this :)
Norm