Option to not (!) expand/collapse group in SfDataGrid on Single Click
Hi,
is there a way to disable the behaviour of expanding/collapsing groups in a SfDataGrid with a single click. I would like to only expand/collapse by clicking on the symbol in column 0 or by double click.
How do I do that?
Regards
Bernd
is there a way to disable the behaviour of expanding/collapsing groups in a SfDataGrid with a single click. I would like to only expand/collapse by clicking on the symbol in column 0 or by double click.
How do I do that?
Regards
Bernd
SIGN IN To post a reply.
7 Replies
SP
Sowndaiyan Paulpandi
Syncfusion Team
July 22, 2016 01:28 PM UTC
Hi Bernd,
Thank you for contacting Syncfusion support.
Thank you for contacting Syncfusion support.
We have checked your query. You can achieve your requirement by override the OnPreviewMouseLeftButtonUp and OnPreviewMouseDoubleClick methods on CaptionSummaryRowControl class like the below code example.
C#
C#
|
public partial class MainWindow : Window {
public MainWindow()
{
InitializeComponent();
this.sfgrid.RowGenerator = new CustomRowGenerator(this.sfgrid);
}
} |
|
public class CustomRowGenerator : RowGenerator {
public CustomRowGenerator(SfDataGrid dataGrid)
: base(dataGrid)
{
}
protected override VirtualizingCellsControl GetVirtualizingCellsControl<T>()
{
if (typeof(T) == typeof(CaptionSummaryRowControl))
{
CustomCaptionSummaryRowControl rowcontrol = new CustomCaptionSummaryRowControl();
rowcontrol.sfDataGrid = this.Owner;
return rowcontrol;
}
return base.GetVirtualizingCellsControl<T>();
}
}
public class CustomCaptionSummaryRowControl : CaptionSummaryRowControl
{
public SfDataGrid sfDataGrid;
public CustomCaptionSummaryRowControl()
: base()
{
this.DefaultStyleKey = typeof(CustomCaptionSummaryRowControl);
}
protected override void OnPreviewMouseLeftButtonUp(MouseButtonEventArgs e)
{
var visualContainer = sfDataGrid.GetVisualContainer() as VisualContainer;
var index = visualContainer.PointToCellRowColumnIndex(e.GetPosition(null));
if (e.ClickCount == 1 && index.ColumnIndex != 0)
return;
base.OnPreviewMouseLeftButtonUp(e);
}
protected override void OnPreviewMouseDoubleClick(MouseButtonEventArgs e)
{
if (this.DataContext is Group)
{
var group = this.DataContext as Group;
if (group.IsExpanded)
sfDataGrid.CollapseGroup(group);
else
sfDataGrid.ExpandGroup(group);
}
base.OnPreviewMouseDoubleClick(e);
}
} |
We have prepared the sample as per your requirements and you download the same from the below location,
Sample : http://www.syncfusion.com/downloads/support/forum/125105/ze/Grouping47763116
Regards,
Sowndaiyan
SR
Sivakumar R
Syncfusion Team
July 23, 2016 05:26 PM UTC
Hi Bernd,
Your requirement can be achieved by handling GroupCollapsing event also. Please refer the below code snippet,
|
dataGrid.AutoExpandGroups = true;
dataGrid.GroupCollapsing += DataGrid_GroupCollapsing;
private void DataGrid_GroupCollapsing(object sender, GroupChangingEventArgs e)
{
e.Cancel = true;
}
|
UG links:
Thanks,
Sivakumar
BE
Bernd
July 25, 2016 11:42 AM UTC
Sowndaiya,
thank you for the sample. It works mostly like expected but it also blocks the single click on the adorner which I'd like to still respond to a single click.
Regards
Bernd
thank you for the sample. It works mostly like expected but it also blocks the single click on the adorner which I'd like to still respond to a single click.
Regards
Bernd
BE
Bernd
July 25, 2016 11:43 AM UTC
Sivakumar,
thank you for the suggestion but this blocks collapsing in general which is not the goal.
Regards
Bernd
thank you for the suggestion but this blocks collapsing in general which is not the goal.
Regards
Bernd
SP
Sowndaiyan Paulpandi
Syncfusion Team
July 26, 2016 03:55 PM UTC
Hi Bernd,
We have checked your reported problem and its working fine in our side. Is it possible to share simple sample to replicate the issue or please modify the our previous provided sample as per your application and revert back to us
Regards,
Sowndaiyan
We have checked your reported problem and its working fine in our side. Is it possible to share simple sample to replicate the issue or please modify the our previous provided sample as per your application and revert back to us
Regards,
Sowndaiyan
BE
Bernd
July 27, 2016 08:32 PM UTC
Sowndaiyan,
I have to aplogize. You sample is behaving perfectly well. I don't know what I did the last time...
Thank you
Bernd
I have to aplogize. You sample is behaving perfectly well. I don't know what I did the last time...
Thank you
Bernd
SP
Sowndaiyan Paulpandi
Syncfusion Team
July 28, 2016 05:28 AM UTC
Hi Bernd,
Thanks for your update.
We are glad that our sample helped you resolving your issue. Please let us know if you need any other assistance.
Regards,
Sowndaiyan
Thanks for your update.
We are glad that our sample helped you resolving your issue. Please let us know if you need any other assistance.
Regards,
Sowndaiyan
SIGN IN To post a reply.
- 7 Replies
- 3 Participants
-
BE Bernd
- Jul 21, 2016 04:39 PM UTC
- Jul 28, 2016 05:28 AM UTC