Angular2 + Ag-grid-是否可以通过按钮上下移动? [英] Angular2 + Ag-grid - Is it possible to move up/down a row with a button?

查看:128
本文介绍了Angular2 + Ag-grid-是否可以通过按钮上下移动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的ag-grid数组有问题,我有这个数组:

I have a problem with my ag-grid array, I have this array :

<div style="width: 100%;">
        <ag-grid-angular #agGrid style="width: 100%; height: 200px;" class="ag-fresh"
                         [gridOptions]="gridOptions"
                         [rowData]="rowData"
                         [columnDefs]="columnDefs"
                         enableColResize
                         rowSelection="multiple"
                         (columnResized)="onColumnEvent($event)"
                         (columnPinnedCountChanged)="onColumnEvent($event)">
        </ag-grid-angular>
    </div>

我有两个按钮:

<div class="bouton" placement="top" ngbTooltip="Déplacer instruction vers le haut">
    <button (click)="moveUp()">
        <img src="/src/images/flechehaut.png" style="width:60px;height:60px;" />
            </button>
</div>
<div class="bouton" placement="top" ngbTooltip="Déplacer instruction vers le bas">
    <button (click)="moveDown()">
        <img src="/src/images/flechebas.png" style="width:60px;height:60px;" />
    </button>
</div>

我想知道是否可以通过向上移动整行按钮,然后使用我的下移按钮向下移动一行。
我查看了 ag -grid文档,但没有发现这种可能性。

And I was wondering if it was possible to move up an entire row with my move up button and to move down a row with my move down button. I looked on the ag-grid documentation but found nothing about this possibility.

至少有可能吗?如果是的话,我应该如何看待这个问题?

Is it at least possible ? And if it is, how should I look into this problem ?

推荐答案

是的,我可以想到两种可能性:

Yes, I can think of two possibilities:


  1. 重新排列rowData并将其重新加载到网格中


    • 这可能会变得很昂贵取决于您有多少行

    • 我当然希望您已对所有列禁用排序,否则您的 moveUp moveDown 函数将毫无用处

  1. Rearrange the rowData and reload it in the grid
    • This may get costly depending on how many rows you have
    • I sure hope you have sorting disabled on all your columns, otherwise your moveUp and moveDown functions would be useless

  • 这将使rowData的顺序与最初发送到网格时的顺序相同,但以特定顺序显示。

  • 我认为可能有可能隐藏此额外的列,并且仍将其保留在所述列上。

这篇关于Angular2 + Ag-grid-是否可以通过按钮上下移动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆