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

Unable to dnd after sorting? #48

Open
pedro-surf opened this issue Sep 22, 2020 · 0 comments
Open

Unable to dnd after sorting? #48

pedro-surf opened this issue Sep 22, 2020 · 0 comments

Comments

@pedro-surf
Copy link

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);
		}
	  }
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant