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
close icon

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

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


4 Replies

JJ Jisha Joy Syncfusion Team 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



DM David Mecteaux 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?



DM David Mecteaux 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.



JJ Jisha Joy Syncfusion Team 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

Loader.
Live Chat Icon For mobile
Up arrow icon