2016-07-09 62 views
0

我正在開發包含可編輯網格刀片的Azure 門戶擴展。 柵格的刀片從選擇器打開,因此包含參數提供者無法更新Azure門戶擴展中的可編輯網格

網格是與參數提供,這是可觀察到的陣列的編輯範圍初始化,啓用行編輯和插入新行

當我嘗試更新的網格,不顯示改變現有的行和創造新的線路產生一個空行,如下圖所示:

Empty line when adding new row

我沒有看到任何錯誤調試時的控制檯。

下面是如何初始化網格:編輯網格的

private _initialize(container: MsPortalFx.ViewModels.PartContainerContract): void { 
    var extensions: number = MsPortalFx.ViewModels.Controls.Lists.Grid.Extensions.EditableRow | MsPortalFx.ViewModels.Controls.Lists.Grid.Extensions.ContextMenuShortcut, 
     extensionsOptions: MsPortalFx.ViewModels.Controls.Lists.Grid.ExtensionsOptions<DataModels.IItem, DataModels.ISelectionItem>, 
     viewModel: MsPortalFx.ViewModels.Controls.Lists.Grid.ViewModel<DataModels.IItem, DataModels.ISelectionItem>; 

    // Set up the editable extension options. 
    extensionsOptions = this._createExtensionsOptions(); 

    // Create the grid view model. 
    viewModel = new MsPortalFx.ViewModels.Controls.Lists.Grid.ViewModel<DataModels.IItem, DataModels.ISelectionItem>(
     container, 
     null, 
     extensions, 
     extensionsOptions); 
    viewModel.showHeader = true; 
    viewModel.columns(this._columns); 
    viewModel.rowAdd =() => { 
     // code that extension authors need to execute when a row is added should go here. 
    }; 
    this.editableGrid = viewModel; 
} 

private _createExtensionsOptions(): MsPortalFx.ViewModels.Controls.Lists.Grid.ExtensionsOptions<DataModels.IItem, DataModels.ISelectionItem> { 
    return <MsPortalFx.ViewModels.Controls.Lists.Grid.ExtensionsOptions<DataModels.IItem, DataModels.ISelectionItem>>{ 
     editableRow: { 
      // Supplies editable items to the grid. 
      editScope: this.parameterProvider.editScope, 
      // put the new row at the top. 
      placement: MsPortalFx.ViewModels.Controls.Lists.Grid.EditableRowPlacement.Bottom, 
      // Create no more than 5 new rows. 
      maxBufferedRows: 5, 
      // Allow the modification of existing items. 
      allowEditExistingItems: true, 
      // Allow the creation of new items. 
      allowEditCreatedItems: true, 
      // Track the valid status 
      valid: ko.observable<boolean>() 
     } 
    }; 
} 

我查看了幾個樣品葉片,但無法確定是什麼我做錯了。

回答

0

問題是,我沒有設置參數提供的editScopeMetadataType財產,這就需要確定編輯範圍的實體類型:

this.parameterProvider = new MsPortalFx.ViewModels.ParameterProvider<DataModels.IItem[], KnockoutObservableArray<DataModels.SchemaItem>>(container, { 

    // This was missing. 
    editScopeMetadataType: wrapperTypeMetadataName, 

    mapIncomingDataForEditScope: (incoming) => { 
     return ko.observableArray(incoming); 
    }, 

    mapOutgoingDataForCollector: (outgoing) => { 
     return outgoing(); 
    } 
});