Hi,
I have Grid where in one column has column moving set to false with index 0. I am trying to move another column with column moving enabled to that index. The grid will allow while moving that column to the Index 0, but after reloading the Grid with the same positions and column settings the original column which was at Index 0 is remaining in that position instead of the moved column.
I am using below function to set the column positions:-
if (scenarioSpecGrdSet.columns.length > 0) { for (var i = 0; i < scenarioSpecGrdSet.columns.length; i++) { $("#" + gridId).igGridColumnMoving("moveColumn", scenarioSpecGrdSet.columns[i].columnKey, scenarioSpecGrdSet.columns[i].newIndex, true, true); } }
Thanks in Advance,
Praveen Divekar
Hello,
If you are trying to restore a certain order of columns that you saved using ColumnMoving's API there is a better option. The moveColumn function is asynchronous which means you'll need additional code to do each of the column rearrangements sequentially. Additionally it will have a negative impact on the performance. What I can suggest is to serialize the columns object after each moving and then when you initialize the grid, parse the stored string into your new columns collection. The solution will look similar to this:
$("#grid1").bind("iggridcolumnmovingcolumnmoved", function (evt, ui) {
// some global variable that stores the serialized columns
savedColumns = JSON.stringify(ui.owner.grid.options.columns);
});
Then when you get the stored string and you want to initialize the grid you can do the following:
$("#grid1").igGrid({
columns: JSON.parse(savedColumns),
...
Please, let me know if I have misunderstood what you are trying to achieve. A small sample demonstrating the issue will help a lot too.
I am looking forward to hearing from you!
Best regards,
Stamen Stoychev
I am still following your case. Have you been able to move on with you project?
If you have any concerns or questions, please feel free to contact me, I will be glad to help you.
Thank you for choosing Infragistics components!
I will Implement the solution given by you. If any problems i will let you know.
Thanks for your Help.
Thanks,
Amit
If i create Custome template with some columns in fixed position then how can i use the above approach and also is that possible to fix the column positions after rendering of the Grid ??
Hello Amit,
With Ignite UI 14.1 the rowTemplate option is deprecated and you won't have to worry about fixed column positions for it. You can only have column templates and as their definitions are part of the columns collection they'll get stored along with the columns' order.
The moveColumn function can still be used to do column rearrangement after the grid has rendered. It is just not the optimal way for restoring an arbitrary order. If you need to set a certain order it's best done through destroying the grid and recreating it with the said order. It will be multiple times faster than doing a multitude of moveColumn calls with each of them involving a good amount of DOM operations.
I hope this helps! Please, let me know if you have any other questions.