Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
70
Column Moving functionality is not working
posted

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

 

Parents
  • 5513
    Offline posted

    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

Reply Children