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
1070
How to change the sort indicator and not perform sort
posted

I am using the XamGrid vs. the XamDataGrid so I hope this is the correct forum for my question. I have also seen this previous post but I did not understand the attached code solution. (http://ko.infragistics.com/community/forums/p/63907/324095.aspx)

I am using .NET 4.0 to build a client application that uses the Infragistics XamGrid to show records for large tables. In the client code we create a .NET DataTable with the correct number of fields and rows as the source table has on the server, but the only value for each row is its primary key which is a simple int. As the user requests a page of records (1000 per page) then the rest of the columns are fetched from the server and written into the data table just for the requested page. This is working well and we are able to show tables that have millions of records without the need to send all the data from the server to the client.

The server also has the ability to sort records and return the sorted results for only the requested page of records. I have wired up the XamGrid_ColumnSorting Event so I can use the custom sorting abilities of the server and cancel the ColumnSorting event.

private void XamGrid_ColumnSorting(object sender, Infragistics.Controls.Grids.SortingCancellableEventArgs e) {
  (this.DataContext as MyViewModel).Execute(......);
  e.Cancel = true;
}

This works well but I need to set the “sort direction” of the column so that its sorting indicator shows up in the column but I cannot figure out how to do this without the grid perform a sort.

I was able to do this with the normal WPF DataGrid. In its Sorting Event we would remember the Column and its SortDirection so that once the server was finished performing the sort, and we updated the ItemsSource of the DataGrid, we could set the SortDirection of the column in the TargetUpdated Event. Then the user could see which column was sorted and in what direction and the next time they clicked on the column to sort we knew its current sort direction.

I really hope it’s possible to set the sort indicator of a column without it actually performing the sort.

BTW should I be using the XamDataGrid or theXamGrid?