Page 1 of 1

JsRender concat values without space

Posted: Sun Dec 31, 2017 10:17 am
by sangnandar

Is there a way to concat custom template (JsRender) values without space?
For example:
fieldA, value = Something
fieldB, value = AnotherSomething

{{{value fieldA}}}{{{value fieldB}}} gives "Something AnotherSomething".

I need "SomethingAnotherSomething".

Thanks.


Re: JsRender concat values without space

Posted: Tue Jan 02, 2018 11:30 am
by mobhar

The closest approach for this is by concating those two fields by using a Custom Field, and then simply display that Custom Field value in your Custom Template.


Re: JsRender concat values without space

Posted: Wed Jan 03, 2018 6:34 am
by sangnandar

Apparently the space is caused by html line-break between <span>'s of fieldA and fieldB.
So I ended up with this solution:
<span name="destroy">{{{value fieldA}}}{{{value fieldB}}}</span> ; // enclose the <span>'s with a <span>

Then destroy the line-break between <span>'s using startup script:
$("span[name=destroy]").each(function(){ //using .each() because it's a List Page
var str = $(this).html().replace(/[\n\r]/g,'');
$(this).html(str);
});

I thinks it's tidier this way since custom field might need additional Row_Rendered() code if the values are lookup.

Thanks btw.


Re: JsRender concat values without space

Posted: Wed Jan 03, 2018 10:22 am
by mobhar

sangnandar wrote:
since custom field might need additional Row_Rendered() code if the values are lookup.

Try to play with "CurrentValue" and "ViewValue" that belongs to the Field object.