【问题标题】:Kendo UI Grid, Group Header not collapsed when using row templateKendo UI Grid,使用行模板时组标题未折叠
【发布时间】:2015-02-17 18:21:38
【问题描述】:

我使用的是 Kendo UI 网格,默认情况下它有一个组。在组标题中,它显示了一些汇总信息。它还使用行模板来显示行信息,即为“真”显示复选标记,为“假”显示十字标记。代码如下:

<script id="rowTemplate" type="text/x-kendo-tmpl">
    <tr>

    <td>

        </td>
    <td>
            #: Portfolio #
        </td>

    <td>
            #: Folder #
        </td>

    <td>
            #: FileName #
        </td>

    <td>
            #: DocumentType #
        </td>

    <td>
            #: ActionTime #
        </td>

    <td>
            #: UserName #
        </td>

    <td>
            #: CompanyName #
        </td>

    <td>
        <img src="Images/downloaded_#:data.Downloaded#.png" alt="downloaded_#:data.Downloaded#.png" />        
        </td>


   </tr>
</script>


var dataSource = new kendo.data.DataSource( {
    schema: {
            model: {
                fields: {
                        ... (some other fields)

                        DocumentType: { type: "string" },
                        CompanyName: { type: "string" },
                        Downloaded: { type: "number" }
                }
            }
    },
    pageSize: 200,

    group: {
        field: "CompanyName", aggregates: [
            { field: "CompanyName", aggregate: "count" },
            { field: "DocumentType", aggregate: "count" },
        ]
    },
    aggregate: [{ field: "CompanyName", aggregate: "count" },
            { field: "DocumentType", aggregate: "count" },
            { field: "Downloaded", aggregate: "sum" },
    ]
    });

    ... (some other configurations)

    dataSource: dataSource,
    columns: [
        ... (some other fields)
        {
            field: "DocumentType", title: "Document Type", width: "80px"
        },
        {
            field: "CompanyName", title: "Company Name", width: "100px"
                    , aggregates: ["count"]
                    , groupHeaderTemplate: "Company Name: #=value# (#=getDownloaded(data)# / #=count#)" 
        },
        {
            field: "Downloaded", title: "Downloaded", width: "50px"             
        },

    ],

    sortable: true,
    filterable: true,
    selectable: true,
    pageable: {
        refresh: false,
        pageSizes: [10, 20, 50, 100, 200],       // true,
        buttonCount: 5
    },

    scrollable: false,
    rowTemplate: $.proxy(kendo.template($("#rowTemplate").html()), dataSource),

});

它工作正常并正确显示网格。但是,如果我单击折叠组标题(屏幕截图下方的黄色圆圈),它不起作用。但是如果我不使用行模板,即注释掉这一行:

rowTemplate: $.proxy(kendo.template($("#rowTemplate").html()), dataSource),

然后它工作正常(但我想显示已下载列的图像)。

这是剑道的错误吗?有谁知道我做错了什么?谢谢。

【问题讨论】:

  • 我不知道它是否是一个错误。我没有遇到过这个。作为一种解决方法,在您弄清楚之前,您可以单独设置每列的模板,看看是否有效。将图像添加到下载列的客户端模板中。
  • 谢谢。有没有像你描述的那样做的代码示例?我对剑道不熟悉,不知道该怎么做。再次感谢。另外,如果您不介意,请将其发布为答案。

标签: kendo-ui kendo-grid kendo-asp.net-mvc


【解决方案1】:

这并不能回答这是否是错误的问题,但您可以查看这是否使您的网格工作。如果您遇到行标题不折叠的问题。想知道是否有隐藏的异常。作为一种解决方法,您可以使用列模板将图像添加到列,就像添加行模板一样。你也试过不使用 $.proxy 吗? ...

{
    field: "Downloaded", title: "Downloaded", width: "50px" ,
    template: kendo.template($("#tmpColumnDownload").html())            
}
..

<script id="tmpColumnDownload" type="text/x-kendo-template">
    <img src="Images/downloaded_#=Downloaded#.png" alt="downloaded_#=Downloaded#.png" />    
</script>

【讨论】:

  • 酷,我实际上从telerik.com/forums/… 找到了答案,但这都是因为你提到了列模板。谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多