Skip to content
This repository was archived by the owner on Aug 19, 2024. It is now read-only.
This repository was archived by the owner on Aug 19, 2024. It is now read-only.

Unable to dnd after sorting? #48

Open
@pedro-surf

Description

@pedro-surf

Is there any examples that show how to make a single column grid sortable and draggable? (unmanaged dragging)
The onRowDragMove event doesn't fire properly.

Each row is an object with only two key-value pairs: name and path. This is what I've tried

function onRowDrag(e) {
		console.log('row drag()')
		let movingNode = e.node;
		let overNode = e.overNode;
		let rowStore = e.api.getRenderedNodes();
		console.dir(rowStore);
	  
		let rowNeedsToMove = movingNode !== overNode;
	  
		if (rowNeedsToMove) {
		  // the list of rows we have is data, not row nodes, so extract the data
		  let movingData = movingNode.data;
		  let overData = overNode.data;
	  
		  let fromIndex = rowStore.indexOf(movingData);
		  let toIndex = rowStore.indexOf(overData);
	  
		  let newStore = rowStore.slice();
		  moveInArray(newStore, fromIndex, toIndex);
	  
		  rowStore = newStore;
		  e.api.setRowData(newStore);
	  
		  e.api.clearFocusedCell();
		}
	  
		function moveInArray(arr, fromIndex, toIndex) {
		  var element = arr[fromIndex];
		  arr.splice(fromIndex, 1);
		  arr.splice(toIndex, 0, element);
		}
	  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions