Can you run a custom field renderer on a template field in a table?

  • 2
  • Question
  • Updated 3 years ago
I have a custom field renderer I like that compares the value of a given field with a benchmark value field and renders the cell on a table red if the value is unfavorable to that of the benchmark value. 

Now I'm trying to pull in data from another model into the table, and I'd like to use the same custom field renderer to compare the value of this new field to my benchmark and render some stuff if different. 

BUT, there's no place to put my field renderer in a template field. I tried to hack the xml by adding snippet="valueHighlight" to my template field in the xml, but no luck. 

Are there any ways to do this?
Photo of Jack Sanford

Jack Sanford, Champion

  • 8,322 Points 5k badge 2x thumb

Posted 3 years ago

  • 2
Photo of Mordechai

Mordechai

  • 968 Points 500 badge 2x thumb
why dont you create a custom renderer that uses the custom template instead of the other way around?
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,436 Points 10k badge 2x thumb
Jack,

Depending upon your needs, a model ui field with an 'if' and 'model lookup' should work as well.

Thanks,

Bill
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Me things you will need to create a second custom renderer.  Choose some other random field on your tables model and bind it to a custom renderer that finds the value from the other model and does the calculation and format manipulation you are interested in... 
Photo of Jack Sanford

Jack Sanford, Champion

  • 8,322 Points 5k badge 2x thumb
Getting there! Thanks Bill for reminding me of Model_Lookup, it is working great to pull the value from my other model into my parent table. The one thing I had to remember was to put my other model FIRST in the model order. 

Now that pulling in the data from the other model is working, I can add a custom field renderer to it. I just need to adjust my field renderer. Currently I have a UI-Only formula field that has my logic in it, which is a complex series of if statements comparing the value of a field to a benchmark value. Then my custom renderer looks to that UI-only field and says if TRUE, render cell as red, and if FALSE render as green. 

So, in order to make this scale, I will need to move that IF logic into the field renderer itself, so it can work dynamically. It's a little harder getting the if/then in Javascript than in the UI-Only formula syntax. 

Thanks everyone!
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
It is harder to do in Javascript - but so much more powerful...