This is a migrated thread and some comments may be shown as answers.

Reorder Grid Columns programmatically

1 Answer 458 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 19 Sep 2012, 08:46 PM
I have 2 grids on top of one another. Users may select items from Grid A (raw data), push a button, and those items will be copied to Grid B (benchmarks). Users may also reorder columns in Grid A, but I'd like to move the columns in Grid B to match when Grid A's move event is complete.

Is this possible out of the box? If user moves column in Grid A, does that change the DataSource metadata? If so, can I just copy the schema & columns from Grid A to Grid B, or is there something better I can be using?

1 Answer, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 24 Sep 2012, 07:05 AM
Hello Angelo,

When you reorder columns in GridA  columnReorder event will be triggered. The arguments for the event are the old index of the column, the new index and the actual column from grid.columns collection.

Then a column is moved to another position except the UI of the Grid its .columns collection is changed.

You can use that event to track when column order is changed on GridA and use the API to reorder (based on some logic) the columns in GridB. To reorder column via the API there is a reorderColumn method exposed. Its arguments are as follow:
 - destination index - the index on which the column should appear
 - column - this is reference to the column from <grid instance>.columns collection

All the best,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Mike
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Share this question
or