RadListBox now supports client templates. The templates are declared in the
ClientItemTemplate
tag and support the following expressions for evaluating
code:
-
#= ... #
- Data - Evaluates the Javascript code expression or a string property
from the data item and outputs the result in the template.
-
# ... #
- Code - Evaluates the JavaScript code expression inside. Does not output value.
-
#: ... #
- HTML-encode - Same as the data expression, but HTML-encodes the result.
The templates are applied automatically to all items loaded through web service.
To apply a client template to an arbitrary item, you have to call the bindTemplate()
function on that item:
function addItem(itemText) {
var item = new Telerik.Web.UI.RadListBoxItem();
var list = $find('<%=RadListBox1.ClientID%>');
item.set_text(itemText);
list.get_items().add(item);
item.bindTemplate();
}
You can also define a specific template to individual items on the client:
function setTemplate(item) {
item.set_clientTemplate("Item Text: #= Text #");
item.bindTemplate();
}