English 中文(简体)
Unable to Reorder Rows within a Group using Row Drag in ag-Grid Angular
原标题:Unable to Reorder Rows within a Group using Row Drag in ag-Grid Angular
The bounty expires in 5 days. Answers to this question are eligible for a +50 reputation bounty. Anil Kumar Reddy A wants to draw more attention to this question.

我在使用Angular和I've的Ag-Grid时,曾遇到过一个使用浏览量特征的集团内部重新排列顺序的问题。

这里,我手法的幻灯塔:CodeSand Box

有了这种安排,我预计能够通过拖拉和退行,重新排队在一个集团内。 然而,这些行文并没有按预期变动。

我在阅读了单方文件并尝试了各种解决办法,但似乎没有一份解决办法。 我不敢肯定,我是否失踪了东西,或者在干.中是否有ug。

问题回答

确保你的浏览数据具有独特的识别特征,可用于识别每一行。 你们可以为此目的利用id。

<>可见> Ag grid

在您的AG-Grid配置中,将遗嘱财产归为独一无二的识别符号(此处为id)。

<ag-grid-angular [getRowId]="getRowId"></ag-grid-angular>

getRowId(params: GetRowIdParams) {
    return params.data.id;
}

onGridReady(params: GridReadyEvent) {
   this.gridApi = params.api;

    // add id to each item, needed for immutable store to work
    immutableStore.forEach(function (data, index) {
       data.id = index;
    });
    params.api.setGridOption("rowData", immutableStore);
}

Implement Row Drag and Drop: Use an immutable store as describe in ag grid documentation

onRowDragMove(event: RowDragEndEvent) {
        var movingNode = event.node;
        var overNode = event.overNode;
        var rowNeedsToMove = movingNode !== overNode;
        if (rowNeedsToMove) {
          // the list of rows we have is data, not row nodes, so extract the data
          var movingData = movingNode.data;
          var overData = overNode!.data;
          var fromIndex = immutableStore.indexOf(movingData);
          var toIndex = immutableStore.indexOf(overData);
          var newStore = immutableStore.slice();
          moveInArray(newStore, fromIndex, toIndex);
          immutableStore = newStore;
          this.gridApi.setGridOption("rowData", newStore);
          this.gridApi.clearFocusedCell();
        }
        function moveInArray(arr: any[], fromIndex: number, toIndex: number) {
          var element = arr[fromIndex];
          arr.splice(fromIndex, 1);
          arr.splice(toIndex, 0, element);
        }
    }

www.un.org/Depts/DGACM/index_spanish.htm 完成不可改变的仓库的价值:

export class AppComponent {
// ...
}
var immutableStore: any[] = getData();




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签