AD
Administrator
Syncfusion Team
January 29, 2004 07:53 AM UTC
Yes, the sorting support in GridDataBoundGrid uses the Tag object to track what column is sorted and how it was sorted.
As a work around, you could create a hashtable to hold your tag objects for the header row. You could use the column mapping name as the key. You can store this hashtable as the Tag in cell 0,0 which is unaffected by the sorting support. Then when you need the tags, access them though cell 0,0. Here are some snippets.
//set up the hashtable
Hashtable ht = new Hashtable();
for(int i = 1; i < this.grid.Model.ColCount; i++)
{
//save some object for each column with mapping name key
//here we just store the original colindex
string key = this.grid.Binder.InternalColumns[i-1].MappingName;
object o = i;
ht.Add(key, o);
}
// store the hashtable as the Tag in cell 0,0
this.grid[0,0].Tag = ht;
//use the hashtable
private void grid_CellClick(object sender, GridCellClickEventArgs e)
{
if(e.RowIndex == 0 && e.ColIndex > 0)
{
Hashtable ht = this.grid[0,0].Tag as Hashtable;
if(ht != null)
{
int fieldNum = this.grid.Binder.ColIndexToField(e.ColIndex);
string s = this.grid.Binder.InternalColumns[fieldNum].MappingName;
object o = ht[s];
if(o != null)
{
Console.WriteLine("column header {0} clicked", o);
}
}
}
}