Indent column width when grouping with SfDataGrid
Thanks for contacting Syncfusion Support.
In SfDataGrid , you can achieve your requirement by customizing the style of “GridExpanderCellControl” like the below code example,
XAML
|
<Style TargetType="syncfusion:GridExpanderCellControl"> <Setter Property="Visibility" Value="Hidden" /> </Style> </Window.Resources> |
Regards,
Sowndaiyan
Attachment: DataGridColumnImage_61efee17.zip
You can hide the indent columns by changing it’s width to zero. Refer the below code snippet where indent columns are hided while loading and also at runtime.
|
this.datagrid.GroupColumnDescriptions.CollectionChanged += GroupColumnDescriptions_CollectionChanged; this.datagrid.ItemsSourceChanged += Datagrid_ItemsSourceChanged;
//Hides indent columns if you have grouped while loading by adding GroupColumnDescriptions private void Datagrid_ItemsSourceChanged(object sender, GridItemsSourceChangedEventArgs e) { if (e.NewItemsSource != null) this.HideIndentColumns(); }
//Hides indents columns when grouping at runtime private void GroupColumnDescriptions_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { this.HideIndentColumns(); }
private void HideIndentColumns() { if (this.datagrid.View == null) return; this.datagrid.Dispatcher.BeginInvoke(new Action(() => { int start = this.datagrid.ShowRowHeader ? 1 : 0; for (int i = start; i < this.datagrid.GroupColumnDescriptions.Count + start; i++) { this.datagrid.GetVisualContainer().ColumnWidths[i] = 0; } }), DispatcherPriority.ApplicationIdle); |
Thanks,
Sivakumar
- 3 Replies
- 3 Participants
-
AR Adam Risberg
- Feb 22, 2016 10:40 AM UTC
- Feb 25, 2016 05:59 AM UTC