I create a datatable and assign it to UltraGrid datasource. The sort order from datatable is not preserved.
e.g. Datatable column sort order (col1, col2, col3). UltraGrid Column sort order (col1, col3, col2).
I want to preserve the UltraGrid column sort order to the sort order in DataTable
e.g. Datatable column sort order (col1, col2, col3).UltraGrid Column sort order (col1, col2, col3).
Please advice
---------------------------------------Here is the code i use.---------------------------
DataTable _table = new DataTable(); for (int i = 0; i < _colKeys.Length; i++) { if (!_table.Columns.Contains(_colKeys[i])) { _table.Columns.Add(_colKeys[i], typeof(string)); _table.Columns[_colKeys[i]].Caption = _colNames[i]; } } _table.Rows.Add(_table.NewRow()); // Value row _table.Rows.Add(_table.NewRow()); // NAV row _mSummaryGrid.DataSource = _table;
The grid displays the columns in the order in which the DotNet BindingManager returns them. I've never seen a case where this is different from the actual data source - assuming the data source has an actual order, which a DataTable certainly does.
So the only way this could happen is if something in your code is rearranging the columns in the grid, either in code or by loading a Layout into the grid.
I see we can manually sort the ultragrid with the below code,
UltraGrid.DisplayLayout.Bands(0).columns("ColumnName").SortIndicator = UltraWinGrid.SortIndicator.Ascending
UltraGrid.DisplayLayout.Bands(0).columns("ColumnName2").SortIndicator = UltraWinGrid.SortIndicator.Descending
This sorting is only applied on the UltraGrid, not on the dataSource used to bind the grid.
Does infragistics has any function to apply the UltraGrid's manually sorting into the dataTable as well ?
Thank you.