I am trying to build some conditional logic in a HTML printer template.
I have found using: [='{PAYMENT TOTAL}' ? '<tr><td style="font-weight:bold">You paid some money<td></tr>' : ''] does not work reliably, I think due to issues of escaping quotation marks…
Anyway… I tried to get around this by using conditional logic to change the display: style attribute of the <tr> element. However it seems that SambaPOS does not respect this style, and still shows the row.
I noticed that <div style="display:none"> is respected.
Is it possible to update the code so that <tr> and <td> elements respect display:none?
It would be great if <tr> and <td> could also respect background:border: and border-color: which right now are respected by <div> but not other elements.
Hi @VehbiEmiroglu - I don’t understand your response. Can you please clarify what you mean.
When I say “it is not respect” display:none, what I mean is that it does not respect the command to hide the element and actually DOES render the element. I would like SambaPOS NOT to render elements with display:none.
The implementation of HTML used in HTML Template is not true HTML, you don’t get full HTML functionality. It basically takes the HTML code you enter and maps it into XAML which is used to generate the printer template. If you want better control, I suggest you use Document Printer and XAML format, it is similar in structure to HTML and there is lots of info about it online.
AFAIK in HTML template format most CSS styles won’t work, so that includes display:none.
EDIT: Actually many CSS styles work, I just haven’t used HTML templates for quite some time as I prefer XAML for better control. But still not display:none.
You can find details about Document Printer near the top of this topic:
However most importantly, your conditional statement is incorrect, and this is why it is not working.
You are using a “ternary operator” and it needs to be
[='Condition to test' ? 'Value if True' : 'Value if False']
So this part '{PAYMENT TOTAL}' is invalud. It needs to return True or False, but all you are doing is testing against a string value of {PAYMENT TOTAL} which will give unexpected results if even work at all.
Thanks @markjw… I will look in to the document printer, and thanks for the tip on how the logic works… I naively thought that it was checking for the presence of any value, not a true/false… I will update the similar statements I am using.
Yep cheers. I found that I was using some of the ideas in to base my new template on. In particular how you must not specicity “px” in border widths and use align=right as an attribute a