Conditional fields and separators

0
shelbert posted this 21 October 2014

Hi,

I need to display Fields separated by commas conditionnally but how to handle the trailing?

Suppose that we have two fields f1 and f2. These fields are conditional so they should be shown like this :

<empty>
f1
f1,f2
f2

if I put the commas into the "if" blocks, I get :

<empty>
f1,
f1,f2, 
f2,

if I put commas chars after the "if" blocks, I get :

,,
f1,,
f1,f2, 
,f2,

I have a lot fields and a lot of possible combinations so, using an "if" block for each combination is not possible. How should I proceed?

Thanks,

Seb

Last edited 21 October 2014

1 Posts
1 Points
1 Comments
Order By: Standard | Newest | Votes
0
jles posted this 22 October 2014

Hi Seb,

Currently there is no way to achieve this with only tagging elements on a template. You will have to either:

  1. Prepare an additional property on your model class that will already hold the resulting value of concatenated string, or

  2. Calculate this resulting string on-the-fly and override/set the FIELD element's value in the EventInitialize event handler.

Both options propose only one FIELD element that would be rendering an already concatenated string which would be "calculated" in your application.

I was assuming here that you are using .NET objects as data sources. In case you are using XML for your data sources, then you simply write XPath expressions that calculate such concatenated string.

Achieving such results will be easy once we introduce scripting/formulas/expressions into templates. But right now if you are populating your templates with .NET Objects, then you will have to resort to C# in your application when you need to implement a more complicated rendering logic.

I hope this helps.

Kindly, Jure Leskovec

Last edited 22 October 2014

154 Posts
294 Points

Our 226165 members have posted 342 times in 101 discussions