0
ag-grid-ng2内に行をドラッグアンドドロップして行を並べ替える必要があります。私はprocessRowPostCreateを使用しましたが、イベント(ondragstart、ondrop)は起動しません。 ご協力いただきありがとうございますag-grid ng2内の行をドラッグアンドドロップする方法(再配列行)
ag-grid-ng2内に行をドラッグアンドドロップして行を並べ替える必要があります。私はprocessRowPostCreateを使用しましたが、イベント(ondragstart、ondrop)は起動しません。 ご協力いただきありがとうございますag-grid ng2内の行をドラッグアンドドロップする方法(再配列行)
私はドラッグアンドドロップfuncに基づいて文章を作成することができました。ここに私のコードです。グリッドが列でソートされたとき(ドラッグ・ドロップは並べ替えのために視覚効果を持たない)、変更をスキップしました。
processRowPostCreate: (params) => {
params.eRow.draggable = true;
params.eRow.ondragstart = (event: DragEvent) => {
this._newRowIndex = params.rowIndex;
this._currentRowIndex = params.rowIndex;
};
params.eRow.ondragenter = (event: DragEvent) => {
this._newRowIndex = params.rowIndex;
};
params.eRow.ondragend = (event: DragEvent) => {
let sortmodel = this.gridOptions.api.getSortModel();
if (sortmodel.length === 0 && this._newRowIndex !== this._currentRowIndex) {
let record = params.node.data;
this.handleRearrangement();
this.records.splice(this._newRowIndex, 0, this.records.splice(this._currentRowIndex, 1)[0]);
this.gridOptions.api.removeItems([params.node], false);
this.gridOptions.api.insertItemsAtIndex(this._newRowIndex, [record], false);
} else {
this._newRowIndex = this._currentRowIndex; // just to be sure
}
};
}