2017-09-16 71 views
0

我們正在使用劍道網格與angularjs,我試圖動態更新列數據,但它不更新列信息。以下是代碼。如何在劍道網格中動態更新列

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, 
    }); 

}

請幫助我如何動態地更新列數據。

UPDATE

我發現爲什麼發生這種情況的原因,是因爲我已經用在當我關閉彈出窗口劍道,但它依舊坐在DOM。如何破壞kendowindow彈出窗口?下面是我的語法:

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(); 

回答

0

這是我的毀滅劍道部件:

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

首先,我detach它從DOM,然後我destroy它。

Demo