All columns in my grid are movable. Now I need to be able to determine the position relative to the target object during a move operation. Unfortunately, I haven't found a way yet, because neither columnMovingEnd, columnMoving nor columnMovingStart provide this information. Also the use of the IgxDrag or IgxGrop directive does not seem to be possible. Is there still a way to determine the position?
Hi André,
Thank you for contacting Infragistics Developer Support!
I have been looking into your question and I believe the IgxGrid Column Moving topic’s Events section would provide some insights on the matter. As you will see in the code-snippets there, the approach to execute custom logic or cancel the moving action is by handling the columnMovingEnd event and performing checks against the event's source and target objects, which are of the ColumnType interface. This means that the position could be checked based on the fields' name (as in the code-snippet example), column index, visible index, or else.
Consequently, I am wondering if you have already attempted this? If you have and you are facing difficulties, my suggestion would be to fork and modify any of our documentation demos, such as this one in an effort to demonstrate what you are currently attempting. In this way we can look into it and eventually provide suggestions.
Additionally, I would not advise going down the road of reimplementing column moving from scratch by leveraging the igxDragDrop directive, since this feature is already built-into the grid as well as fully tested and it is highly likely that your scenario could be implemented via the currently exposed API.
Please, keep me posted on your progress.
Best regards,Bozhidara PachilovaAssociate Software Developer
Thank you very much for your reply. Yes, I have already tried to implement your suggestions. However, I am not achieving my goal. The problem is that the targetIndex is the index before the move. This means that only the ColumnElement is returned (with the index before the move is completed). However, the information is also needed where the source element must be inserted (before or after)
public onColumnMovingEnd(event: IColumnMovingEndEventArgs){ // index of the current source column --> before moving const sourceIndex = event.source.index console.log(sourceIndex) // index of the current target column --> before moving const targetIndex = event.target.index console.log(targetIndex) //case : sourceIndex < targetIndex && drop the source element above the left side of the target element // indexAfterDro = targetindex //case : sourceIndex < targetIndex && drop the source element above the right side of the target element // indexAfterDro = targetindex + 1 }