Declined
Last Updated: 16 Dec 2021 11:50 by ADMIN
Willy
Created on: 23 Jan 2017 17:33
Category: Templates
Type: Feature Request
2
Allow the "Template" property for combox and dropdownlist to return a HtmlElement instead of string
For all the “items” controls that have a “Template” configuration property to define the items (for example: combobox, dropdownlist) the documentation tells me the template property can be a string or function.
If a function is used this function should return a string presentation of the Html you want to be rendered. 
I would like to have this template functionality enhanced so the function can also return an HtmlElement or HtmlFragment instead of a string. So the template function is fully responsible to construct the Html that will be inserted into the dom. Your template processing only has to check if the return type of the function is an instance of a HtmlElement or HtmlFragment an take the result of the function as it is. No further processing needed. 
Reasoning behind this feature request is:
In my development I try to move away from string based definition of Html as far as possible. Because this string based definition of Html and Htmltemplates is the weak part of a modern SPA architecture. No designtime checking of the content of these Html with its binding expressions is possible.
Therefore I developed a component to define my  HtmlElements or HtmlFragments in a strong typed way. This component has full support for designtime checking of properties and binding expressions. The result from my component however is an HtmlElement not a “String”. Now i have to work around this by serializing the HtmlEment to  a string. This not only is a waste of performance but also makes it impossible to attach event handler to the hmlElement or it children.

0 comments