Hi Haritos,
I agree the use of the template is not straightforward...
It is a little bit strange we need to provide the template and I didn't made it mandatory (like abstract)... I will need to double check that.
Anyway, the rule for the templates is that the template-text should embed the kendo data properties (like #: data.firstName #).
Normally for these variable to be interpolated, the bean properties (like "firstName") should be provided too (by getTextProperty).
Maybe it is not needed for the DataView template to override getTextProperty because it already has a JsonRenderer, but just in case you can override it like bellow:
So at the end you can have something like:
return new IJQueryTemplate() {
private static final long serialVersionUID = 1L;
@Override
public String getText()
{
return "<span data-key='#: data.key #'>" // lf
+ "<img class='gravatar' src='#= data.gravatarImageUrl #' title='#: data.firstName # #: data.lastName #' />" // lf
+ "</span>";
}
@Override
public List<String> getTextProperties()
{
return Arrays.asList("firstName", "lastName", "gravatarImageUrl");
}
};
If your template is rather big, you can opt for a dedicated tmpl file
MyDataView.java
@Override
protected IJQueryTemplate newTemplate()
{
return new JQueryPackageTextTemplate(MyDataView.class) {
private static final long serialVersionUID = 1L;
@Override
public List<String> getTextProperties()
{
return Arrays.asList("email", "firstName", "lastName", "gravatarImageUrl");
}
};
}
MyDataView.tmpl (same class name)
<div class='my-class'>
<img class='gravatar' src='#= data.gravatarImageUrl #' alt='#: data.email # ' />
#: data.firstName # #: data.lastName #
</div>
Additionally you can also provide variables to the template
final Map<String, Object> variables = Generics.newHashMap();
variables.put("var1", "boup");
new JQueryPackageTextTemplate(MyDataView.class, variables);
in the template, you can retrieve the value using the "${var1}" notation
Note that there is also the DataViewPanel that embed the Pager by default
Hope this helps,
Sebastien