【问题标题】:Change width of Kendo UI Grid Hierarchy?更改 Kendo UI Grid Hierarchy 的宽度?
【发布时间】:2017-10-22 05:00:14
【问题描述】:

我有一个包含 3 列层次结构的 13 列网格。

问题是层次网格平均占用 13 列空间来显示 3 列。

有没有办法设置层次网格的宽度?

【问题讨论】:

    标签: jquery kendo-ui kendo-grid


    【解决方案1】:

    为了为层次网格设置更小的宽度,您可以显式设置层次网格组件的宽度。这可以通过 HtmlAttributes 属性来完成。

    .HtmlAttributes(new {style="width: 500px;" })
    

    【讨论】:

    • 这对于设置子网格的宽度非常有效。
    【解决方案2】:

    我想这就是你要找的答案。

    function resizeDetailGrid(gridElement) {
        // resize detail column widths to match master column headings
        gridElement.find('.k-detail-cell tbody tr td').each(function (index) {
            var headerCell, detailCell, headerCellSelector, detailCellSelector;
            headerCellSelector = kendo.format('.k-master-row td:nth-child({0})', index + 2);
            detailCellSelector = kendo.format('.k-detail-cell tbody tr td:nth-child({0})', index + 1);
            headerCell = gridElement.find(headerCellSelector).first();
            detailCell = gridElement.find(detailCellSelector);
            detailCell.width(headerCell.width());
        });
    }
    

    并初始化网格

        gridDetailInit: function () {
            resizeDetailGrid($('#grid'));
        }
    

    如果您有这么多列,您还可以在网格中添加一个水平滚动条。

    希望这些信息对您有所帮助。

    猜你喜欢
    • 1970-01-01
    • 2012-10-08
    • 1970-01-01
    • 2012-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-29
    • 1970-01-01
    相关资源
    最近更新 更多