We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

GGC Sorting Header Row

Hi,

Can you please help me to sort header row of GGC.
I want to sort header row using a field which is in the same datasource but not binded to the header or child row.

Here is the code I am using to bind the GGC

grdWbsTask.DataSource = ProjectScopeManager.ScopeSubTaskDT;
grdWbsTask.ChildGroupOptions.CaptionText = "{Category}";

grdWbsTask.TableDescriptor.GroupedColumns.Add("group");
GridColumnDescriptor subTaskName = new GridColumnDescriptor();
subTaskName.Name = "name";
subTaskName.MappingName = "name";
subTaskName.HeaderText = "Name";
grdWbsTask.TableDescriptor.Columns.Add(subTaskName);

GridColumnDescriptor constantHours = new GridColumnDescriptor();
constantHours.Name = "loe_constant_hours";
constantHours.MappingName = "loe_constant_hours";
constantHours.HeaderText = "LOE(Hours)";
grdWbsTask.TableDescriptor.Columns.Add(constantHours);

Thanks
Saman

4 Replies

LS Lingaraj S Syncfusion Team June 20, 2009 11:29 AM UTC

Hi Samanvay,

Thank you for your interest in Syncfusion product.

I am unable to reproduce the issue in sorting, when the column has been added manually in GridGroupingControl. I have created the sample with specified your code in GridGroupingControl, the header sorting had performed in GridGroupingControl. Also I have attached the sample in below link:
http://files.syncfusion.com/support/samples/Grid.Windows/Forums/GGCBindColumn.zip

This sample shows the sorting in GridGroupingControl.

Please try this sample, let me know if I misunderstood the query.

Regards,
Lingaraj S.


SG samanvay Gupta June 22, 2009 10:52 AM UTC

Hi Lingaraj,

Thanks for your quick comment on this. I probably could not explain the problem correctly.

Attached is the sample which I have created to explain the problem. In this sample I would like to sort header row (currently 3 rows) programmatically by "task index" field. Currently header rows are sorted based on thier caption.

task index field is associated with child rows but it will remain same for all the rows of that group

Thanks
Saman





GGCControl_3e96c1fb.zip


SG samanvay Gupta June 25, 2009 07:29 AM UTC

Hi Lingaraj,

I would really appreciate if you look into this ASAP.

Thanks,
Samanvay


LS Lingaraj S Syncfusion Team June 26, 2009 11:49 AM UTC

Hi Samanvay,

Thank you for the update.

If you want to sort grouped column by clicking another column, then please try using ListSortSortDirection property in GroupedColumns by applying in TableControlCellClick event to achieve this behavior.

Refer the code below:

void gridGroupingControl1_TableControlCellClick(object sender, GridTableControlCellClickEventArgs e)
{
GridTableCellStyleInfo sty = this.gridGroupingControl1.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex);
if (sty.TableCellIdentity.TableCellType == GridTableCellType.ColumnHeaderCell && sty.TableCellIdentity.Column.Name == "task_index")
{
System.ComponentModel.ListSortDirection sort= this.gridGroupingControl1.TableDescriptor.GroupedColumns["group"].SortDirection;
if (sort == ListSortDirection.Ascending)
{
sort = ListSortDirection.Descending;
this.gridGroupingControl1.TableDescriptor.GroupedColumns["group"].SortDirection = sort;
}
else
{
sort = ListSortDirection.Ascending;
this.gridGroupingControl1.TableDescriptor.GroupedColumns["group"].SortDirection = sort;
}
e.Inner.Cancel = true;
}
}


Refer the modified sample in below link:
http://files.syncfusion.com/support/samples/Grid.Windows/Forums/GGCControlModified.zip

Please let me know if you have any queries.

Regards,
Lingaraj S.

Loader.
Live Chat Icon For mobile
Up arrow icon