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é,
I understand and what I can say is that it is indeed the case that the expected positions after the column moving action has completed are not provided by the columnMovingEnd event arguments. This event is cancelable, therefore at the point of firing it, the coulmns have not been moved yet, therefore their “before” indexes are what the source/target column objects have as property values.
Now, I agree that the source column position after could not be derived solely from the target in this case without knowing the DropPosition (before/after) the target column.
So, this could be a candidate for a feature request, which you could log in our GitHub repository here. Remember to explain your requirement and scenario in detail in order to communicate why this feature would be valuable for you.
Alternatively and as mentioned, in case you were to provide some more details about the target behavior in this case maybe we could figure an alternative approach to achieving your requirement. Is the precise column position absolutely required for your scenario? Wouldn’t simply knowing which target column will be reordered as a result of dropping the source column, be sufficient to cancel the event (or perform some other action), or is the knowledge about whether the column will be dropped to the left/right of the target also meaningful in this case? What action should be performed with this information?
Best regards,Bozhidara Pachilova
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 }
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