I was looking for something similar - I wanted column drops on the grouping bar.
It fires on "actionComplete". I'm pretty sure that fires on most things you can do, and it's the last event that fires.
As for the columns, I think you're going to have to save the state of the columns on load, and then compare after the actionComplete. I think off the event you can find the column model in grid.model.columns. That's as far as I went. My use case was a custom export to excel where I needed to have the excel sheet have the same columns in the same order if the user re-ordered them, hid some columns, etc. Everything about the columns is in that model.columns array.
As a fact, model.columns does not change just for a column reordering. I inspected that several times, and if any change is stored, may be in some other property like views and so on, however I did seek a proper and "approved" way to meet my requirements so I have not to dread for the next release changing some "internals" I improperly relay on. It is either the event or the way the target of the event is choosed to make me know exactly the new position.
The original position I know, for I store myself in my structures, but I have to update it when a column has moved.
Where it has moved (before or after the target of the event) it seems difficult to find out. May be it is always "before" or "after", which in turns may means "instead of" or "beside" considering direction it has taken.
columnDrop: function (args) {
var columnName = args.column.field;
for(var i=0 ; i < args.model.columns.length; i++ ){
if(args.model.columns[i].field == args.column.field)
var lastTarget = i+1;
if(args.model.columns[i].field == args.target.attr("data-ej-mappingname"))
var currentTarget = i+1;
}
console.log(columnName + " column is moved from " + lastTarget + " position to " + currentTarget+ " position" )
}, |
Hi Prasanna,
I will check you kindly provided snippet soon, yet I don't know if the column is dropped before or after the target.
Meanwhile you wrote:
"In this you have mentioned that once we performing reordering in Grid you also need to change the order in this.model.columns. So, please provide more information for the purpose of changing the order in this.model.columns."
Probably my English is not as well as I thought, as you point-out, I have not such a requirement. Just noticed that the model is preserved unchanged, I just need to know the new Index. In a few day I'll will back here to report how it works the snippet (concept) you just fournished.
For the present I thank you for your assistance,
Read me soon,
Marco
Hi Prasanna,
I've tried your solution and deterministically works, regardless of which direction the column is moved, so the keypoint was: "target" it is always the column preceding the dropped one, so a +1 is required.
Please take note of the other thread of mine (https://www.syncfusion.com/forums/132043/custom-header-template) for when using that custom header template this snippet is not even invoked.
Thank you for you kind support,
Marco