如何在kendo网格中动态更新列

时间:2017-09-16 08:00:28

标签: kendo-ui

我们正在使用带有angularjs的kendo网格,我试图动态更新列数据,但它没有更新列信息。以下是代码。

function loadSelectRowsGrid(gridData) {

    var selectRowsGridID = "#rowsConfiguration-Grid";
    var grid = $(selectRowsGridID).data("kendoGrid");
    if (grid !== undefined && grid.dataSource.options.data !== null) {
        grid.destroy();
       }

    pcService.rowConfiguration.configurationItem = [];
    pcService.columnCollection.columns = [];

    var maxColumnCount = 3
    for (var i = 0 ; i <= maxColumnCount; i++) {
        if (i != 0) {
            //var columnObject = { "field": gridData.columnData[i].field };//+ "," + "title:" + localizationService.GetLocalizedText(gridData.columnData[i].field);
            var columnObject = { "field": gridData.columnData[i].field, "title": localizationService.GetLocalizedText(gridData.columnData[i].field) };
            pcService.columnCollection.columns.push(columnObject);
        }
        else {

        }
    }

    $(selectRowsGridID).kendoGrid({
        dataSource: {
            data: gridData.gridData,
        },
        columns: pcService.columnCollection.columns, //gridData.columnData, 
        scrollable: false,
    });

}

请帮助我动态更新列数据。

更新

我找到了发生这种情况的原因,因为我使用了kendo窗口,当我关闭弹出窗口时它仍然在DOM中。如何破坏kendowindow popup?以下是我的语法:

var selectRowsDialog = $("#select-Rows-dialog").kendoWindow({ 
    width: "800px", 
    title: "Select rows", 
    autoOpen: false, 
    closable: true, 
    modal: true, 
    visible: false, 
    close: function () { }, }).data("kendoWindow").center().open();

1 个答案:

答案 0 :(得分:0)

这是我销毁剑道小部件的方法:

$("#wnd")
    .detach()
    .data("kendoWindow")
        .close()
        .destroy();

首先我detach来自DOM,然后我destroy它。

Demo