如何格式化ListView的Kendo UI外部模板中的参数集?

时间:2013-04-24 17:12:42

标签: jquery listview kendo-ui

我有一个Kendo UI外部模板,如下所示:

<script type="text/x-kendo-tmpl" id="dispositivosTemplate">
    <div class="containerElement" style="background-color: transparent" value="${UniqueId}" onclick="showSubsettingDetails(this)">
        <dl>
            <dd class="elementList dispositivoElement">${UniqueId}: ${Ubicacion}</dd>
        </dl>
    </div>
    <br/>
</script>

我使用以下代码设置此模板:

var template = '#dispositivosTemplate';
var dataSourceList = new kendo.data.DataSource({
    data: src
});
$('#listView').kendoListView({
    dataSource: dataSourceList,
    template: kendo.template($(template).html())
});

其中 src 是通过AJAX调用获得的对象数组,每个对象都有一个字符串类型的 Ubicacion 属性,该值往往很长。

我想要做的是给格式化 Ubicacion 在我的Kendo UI ListView中显示的方式,例如,而不是在ListView中的项目中显示以下内容< em>“Calle Santa Lucia,墨西哥州,墨西哥”,更改它,使其看起来像“Called Santa Lucia ...”而不更改中的原始值Ubicacion 属性。

任何帮助将不胜感激。感谢。

1 个答案:

答案 0 :(得分:1)

此处解释了模板定义中javascript代码的用法: http://demos.kendoui.com/web/templates/expressions.html

但是,如果您只想缩短显示的文字,那么您可能需要查看text-overflow: ellipsis css属性

编辑:甚至更好的教程在这里: http://docs.kendoui.com/getting-started/framework/templates/overview