In my databound grid, when the user double clicks on a column,
I want to use my own custom sorting method. So I created a hidden column
"SortOrder" and changing the values in that column everytime the
user double clicks on a col header. After that I use currencymanager
and bindinglist to sort it.
In the attached sample, I have derived from DataboundGrid(126.96.36.199
VS.NET 2003) and it has datatable (which is part of a dataset) as
the datasource. I have overridden the SortColumn(int colIndex) method
from base class. I cut/pasted SortField() code from the Syncfusion
databound grid. I commented out BinderSort(fieldNum) and added my
sorting logic there. In my sorting logic, I am updating
Run the attached sample, keep double clicking on the name column to
see the values scrolling. I want to suppress the painting until
sorting is completed.
Eventhough I have BeginUpdate() and EndUpdate() around my code, why is
the grid painting? Also, Is there anyway to show the sort icon on
current column header even though I am sorting on "SortOrder" column?
ADAdministrator Syncfusion Team October 3, 2003 10:47 AM
Call SuspendBinding after BeginUpdate and ResumeBinding after EndUpdate:
public override void SortColumn(int colIndex)
bool hasCC = CurrentCell.HasCurrentCell;
//int colIndex = CurrentCell.ColIndex;
int fieldNum = this.Binder.ColIndexToField(colIndex);
Console.WriteLine("Customer Sorting fieldNum = " + fieldNum);
// use custom sorting
string fieldName = this.Binder.InternalColumns[fieldNum].MappingName;
DataTable table = this.DataSource as DataTable;
SortTable(fieldName, table, GetSortDirection());
BTW - I recently worked on a similar example so that you can sort a databound grid with the foreign key of a combobox displaymember. I'll attach it although it looks like you already got it working your way. But maybe it still helps.
ADAdministrator Syncfusion Team October 3, 2003 02:17 PM
Thank you very much for your reply.
Now my painting problem is gone. I have a complex tree sorting that can not be done using the datasource technique you mentioned above.
How can I show the little sort direction icon in my header cell on which the user double clicked (even through I am actually sorting based on a hidden column 'SortOrder')?
I tried setting this[0, curColIndex].Tag = ListSortDireciton.Ascending. It does not work.
ADAdministrator Syncfusion Team October 3, 2003 03:33 PM
You need to do that in QueryCellInfo. Check out the QueryCellInfo code in the sample. You should do something similar.