angularjs - 在 wijmo 网格 angular2 的开头添加新的空行

标签 angularjs angular wijmo5

我试图在单击外部按钮时在网格的开头添加一个新的空行。网格显示非常好。

<wj-flex-grid #flex 
    [itemsSource]="data" 
    [isReadOnly]="true" 
    [headersVisibility]="'Column'" 
    [selectionMode]="'ListBox'" 
    (selectionChanged)="gridSelectionChange($event, flex)" 
    (loadedRows)="onGridLoaded($event)">
</wj-flex-grid>

和使用 collectionView 的数据:

this.data = new wjcCore.CollectionView(records);

使用[allowAddNew] = 'true',默认在底部添加新行。 但我想在按钮点击开始时添加。

更新:

addNewRow(ctl) {
    this.data.addNew();
}

addNewRow 工作正常但在 bottom 中添加:

<a (click)="addNewRow(flex)">add new</a>

请帮助我如何实现这一目标。

谢谢

最佳答案

为了将新行设置在顶部,wijmo grid 提供了一个属性newRowAtTop

修改你的代码如下:

<wj-flex-grid #flex 
    [newRowAtTop] = "true"
    [itemsSource]="data" 
    [isReadOnly]="true" 
    [headersVisibility]="'Column'" 
    [selectionMode]="'ListBox'" 
    (selectionChanged)="gridSelectionChange($event, flex)" 
    (loadedRows)="onGridLoaded($event)">
</wj-flex-grid>

注意上面代码中的[newRowAtTop] = "true"部分。

newRowAtTop 的以下描述是从 this 复制的链接:

Gets or sets a value that indicates whether the new row template should be located at the top of the grid or at the bottom.

If you set the newRowAtTop property to true, and you want the new row template to remain visible at all times, set the frozenRows property to one. This will freeze the new row template at the top so it won't scroll off the view.

The new row template will be displayed only if the allowAddNew property is set to true and if the itemsSource object supports adding new items.

关于angularjs - 在 wijmo 网格 angular2 的开头添加新的空行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41357153/

相关文章:

angularjs - AngularJS 对多页面应用程序有用吗

angularjs - 如何仅对 ag 网格中的某些行禁用编辑

Angular 9 在 ngAfterViewInit 生命钩子(Hook)上返回不正确的元素高度

html - ag 网格水平滚动

angular - 使用 Material design 图标代替 PrimeNg 的 Font awesome

javascript - Angular 5 升级构建问题, Uncaught ReferenceError : define is not defined

javascript - 当我更改选择选项时,ng-model 没有更新

javascript - 根据嵌套指令 Angular 的宽度更改文本