Say I have a table with columns AA, BB, CC, DD and, via the More menu under the filtering and grouping options, I turn off the AA column and rearrange the others so that it is displayed as CC, BB, DD.
I then do:
var dataView = dataGrid.GetDataView();
var rows = dataView.Cast<DataRowView>().Select(x => x.Row).ToList();
Then if I iterate through the rows[index].ItemArray, the fields are in the original order (AA, BB, CC, DD). I can look at the RadDataGrid.Columns and see if the column IsVisible, but if I use the index in the ItemArray on the Columns, I won't get the right column.
What am I missing? It seems like the DataView should have the data in the order presented or that the Columns collection should have a way to map the ordering. After all, the DataView does present the filtering, grouping, and sorting correctly.
I wrote code to do my own mappings, but it's kind of ugly and seems unnecessary - there should be a way to either get the data in the order presented or get the columns in the order presented.
As for why I'm doing this - I'm using the DataGrid in a UWP and iPad Xamarin.Forms app to take report output and let the user's rearrange columns, filter, sort, turn off unwanted columns, etc. then export to Excel in a WYSIWYG fashion - the export should look like the current state of the DataGrid.