我正在使用以下功能(我从网络获得)来调整kendo ui中列的大小。
这是基于索引,我正在寻找是否可以通过列标题或字段/键来选择。

当我重新排序网格列时,此功能失败。

 function resizeColumn(idx, width) {
            $("#grid .k-grid-header-wrap") //header
               .find("colgroup col")
               .eq(idx)
               .css({ width: width });

            $("#grid .k-grid-content") //content
               .find("colgroup col")
               .eq(idx)
               .css({ width: width });
        }

最佳答案

要按列标题调整大小,您只需要找出正确的索引即可,例如像这样:

function resizeColumn(title, width) {
    var index = $("#grid .k-grid-header-wrap").find("th:contains(" + title + ")").index();

    $("#grid .k-grid-header-wrap") //header
        .find("colgroup col")
        .eq(index)
        .css({ width: width });

    $("#grid .k-grid-content") //content
        .find("colgroup col")
        .eq(index)
        .css({ width: width });
}

09-25 17:46
查看更多