Kendo Grid:如何显示List< string>在一个单元中? [英] Kendo Grid: How display List<string> in one cell?

查看:197
本文介绍了Kendo Grid:如何显示List< string>在一个单元中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试遍历列表并将所有元素显示在列中的单元格中,但是我无法使其正常工作.

I tried to iterate through the list and display all elements into a cell in a column but I've having trouble getting it to work.

这是我到目前为止所拥有的.

Here is what I have so far.

在网格定义中:

columns.Bound(x => x.locationList).Title("Locations Included").ClientTemplate("#= iterate(x.locationList) #");

其中,x.locationList是传入的对象中的List<string>.

where x.locationList is a List<string> in the object passed in.

<script>中:

function iterate(object) {
        var html = "<ul>";

        for (var x = 0; x < object.length; x++) {
            html += "<li>";
            html += object[x];
            html += "</li>";
        }

        html += "</ul>";
        return html;
}

但是,这将导致所有记录消失.正确的语法是什么?

However, this causes all the records to disappear. What is the correct syntax to do this?

文档令人困惑,大多数示例不适用于我要尝试的内容.

The documentations are confusing and most of the examples don't apply to what I'm trying to to.

推荐答案

您是如此亲密!实际上,您在定义Kendo网格的位置仅差了一个字母.传递给iterate函数时,只需将x.locationList替换为locationList,就可以了! (下面有修正的完整行)

You were so close! You were literally one letter off where your Kendo Grid was defined. Just replace the x.locationList with locationList when passing to your iterate function and you're good to go! (Full line with fix below)

    columns.Bound(x => x.locationList).Title("Locations Included").ClientTemplate("#= iterate(locationList) #");

这篇关于Kendo Grid:如何显示List&lt; string&gt;在一个单元中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆