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
215
UltraGrid columns sort order is different than Datatable column sort order. Why ?
posted

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;

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    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.

Children