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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Why can''t you group columns that have been frozen?

Thread ID:

Created:

Updated:

Platform:

Replies:

96820 Oct 7,2010 05:45 PM UTC Oct 12,2010 06:57 AM UTC Windows Forms 4
loading
Tags: GridControl
David Mecteaux
Asked On October 7, 2010 05:45 PM UTC

Is there a way to allow columns that are frozen to be grouped? If not why is that the case?


Jisha Joy [Syncfusion]
Replied On October 11, 2010 11:45 AM UTC

Hi David,

With the FrozenColumn setting in GridGroupingControl, grouping by that frozen column cannot be achieved. However this can be achieved by handling FreezeRange() method call. Here is the code for your reference.

field = this.gridGroupingControl1.TableDescriptor.NameToField("SNo");
col = this.gridGroupingControl1.TableDescriptor.FieldToColIndex(field);
this.gridGroupingControl1.TableModel.Cols.FreezeRange(col,col+2);

With this code, you can set the column with name "SNo" and two subsequent columns as frozen columns.

While handling the grouping, the column index get changed based on the groupedcolumns count. Hence to retain these columns as frozen, the PropertyChanged event can be handled while grouping occurs and the freeze range can be retained accordingly with the following code in it.

if (e.PropertyName == "TableDescriptor")
{
Syncfusion.Grouping.DescriptorPropertyChangedEventArgs prop = e.Inner as Syncfusion.Grouping.DescriptorPropertyChangedEventArgs;
if (prop.PropertyName == "GroupedColumns")
{
this.gridGroupingControl1.TableModel.Cols.RestoreFrozen();
field = this.gridGroupingControl1.TableDescriptor.NameToField('SNo');
col = this.gridGroupingControl1.TableDescriptor.FieldToColIndex(field);
this.gridGroupingControl1.TableModel.Cols.FreezeRange(1, col+2);
}
}


Please refer to the sample in the following link in which this has been implemented.
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=I717961512226581.zip

Regards,
Jisha


David Mecteaux
Replied On October 11, 2010 01:30 PM UTC

Thanks that code works.
I do have one concern about it though. Its very slow when you group columns that are frozen. It is much slower than if I wasn't using that code. Is there anyway around this?


David Mecteaux
Replied On October 11, 2010 04:14 PM UTC

Actually I have one more issue with this other than it sometimes being very slow. How can I prevent the user from dragging a frozen column to another column? I would like for the user not to be able to move any of these frozen columns.


Jisha Joy [Syncfusion]
Replied On October 12, 2010 06:57 AM UTC

Hi David,


Please try handling the following code snippet to disable dragging of frozen columns. This has been achieved by handling the TableControlQueryAllowDragColumn event.


this.gridGroupingControl1.TableControlQueryAllowDragColumn += new Syncfusion.Windows.Forms.Grid.Grouping.GridQueryAllowDragColumnEventHandler(gridGroupingControl1_TableControlQueryAllowDragColumn);

void gridGroupingControl1_TableControlQueryAllowDragColumn(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridQueryAllowDragColumnEventArgs e)
{
string colName = e.TableControl.TableDescriptor.FrozenColumn;
int colIndex = e.TableControl.TableDescriptor.Columns.IndexOf(colName);
int frozenColIndex = e.TableControl.TableDescriptor.Columns.IndexOf(e.Column);
if (frozenColIndex <= colIndex)
e.AllowDrag = false;

else
e.Handled = true;

}

Please refer the modified sample that allows us to drag drop frozen columns without any performance hit.

Regards,
Jisha



Sample11_6a0ebb6a.zip

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;