|
public class ColumnChooserPopupExt : Syncfusion.WinForms.DataGrid.Interactivity.ColumnChooserPopup
{
private SfDataGrid DataGrid { get; set; }
public ColumnChooserPopupExt(SfDataGrid sfDataGrid) : base(sfDataGrid)
{
this.Controls.Remove(this.ColumnChooser);
DataGrid = sfDataGrid;
ColumnChooser = new ColumnChooserExt(sfDataGrid);
////UnComment this if you want to close the popup when OK button is clicked
//ColumnChooser.OKButton.Click += Close_ColumnChooserPopup;
ColumnChooser.CancelButton.Click += Close_ColumnChooserPopup;
ColumnChooser.BorderStyle = BorderStyle.None;
ColumnChooser.ColumnChooserLabel.Visible = false;
this.Controls.Add(ColumnChooser);
}
private void Close_ColumnChooserPopup(object sender, EventArgs e)
{
if (this.DataGrid.GetTopLevelParentDataGrid().FindForm() != null)
this.DataGrid.GetTopLevelParentDataGrid().FindForm().Focus();
this.Hide();
}
}
public class ColumnChooserExt : Syncfusion.WinForms.DataGrid.Interactivity.ColumnChooser
{
/// <summary>
/// The grid attached with the column chooser.
/// </summary>
private SfDataGrid dataGrid;
/// <summary>
/// Initializes a new instance of the sfDataGrid
/// </summary>
/// <param name="sfDataGrid">The data grid which needs to be attached to the control.</param>
public ColumnChooserExt(SfDataGrid sfDataGrid) : base(sfDataGrid)
{
dataGrid = sfDataGrid;
dataGrid.Columns.CollectionChanged += Columns_CollectionChanged;
}
private void Columns_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
this.CheckedListBox.DataSource = dataGrid.Columns.Where(x => x.MappingName != "OrderID" && x.MappingName != "CustomerID");
}
protected override void AddCheckedListBox()
{
base.AddCheckedListBox();
this.CheckedListBox.DataSource = dataGrid.Columns.Where(x => x.MappingName != "OrderID" && x.MappingName != "CustomerID");
}
protected override void OnSearchBoxTextChanged(object sender, EventArgs e)
{
base.OnSearchBoxTextChanged(sender, e);
List<GridColumn> searchedItems = new List<GridColumn>();
if (!string.IsNullOrEmpty(this.SearchTextBox.Text))
{
searchedItems.Clear();
searchedItems = this.dataGrid.Columns.Where(item => (item.HeaderText.ToLower().Contains(this.SearchTextBox.Text.ToLower()) && item.MappingName != "OrderID" && item.MappingName != "CustomerID")).ToList();
this.CheckedListBox.DataSource = null;
this.CheckedListBox.DataSource = searchedItems;
}
else
this.CheckedListBox.DataSource = dataGrid.Columns.Where(x => x.MappingName != "OrderID" && x.MappingName != "CustomerID");
this.CheckedListBox.Invalidate();
} |
|
public class ColumnChooserPopupExt : Syncfusion.WinForms.DataGrid.Interactivity.ColumnChooserPopup
{
private SfDataGrid DataGrid { get; set; }
public ColumnChooserPopupExt(SfDataGrid sfDataGrid) : base(sfDataGrid)
{
this.Controls.Remove(this.ColumnChooser);
DataGrid = sfDataGrid;
ColumnChooser = new ColumnChooserExt(sfDataGrid, new ObservableCollection<string>() { "OrderID", "CustomerID" });
////UnComment this if you want to close the popup when OK button is clicked
//ColumnChooser.OKButton.Click += Close_ColumnChooserPopup;
ColumnChooser.CancelButton.Click += Close_ColumnChooserPopup;
ColumnChooser.BorderStyle = BorderStyle.None;
ColumnChooser.ColumnChooserLabel.Visible = false;
this.Controls.Add(ColumnChooser);
}
private void Close_ColumnChooserPopup(object sender, EventArgs e)
{
if (this.DataGrid.GetTopLevelParentDataGrid().FindForm() != null)
this.DataGrid.GetTopLevelParentDataGrid().FindForm().Focus();
this.Hide();
}
}
public class ColumnChooserExt : Syncfusion.WinForms.DataGrid.Interactivity.ColumnChooser
{
/// <summary>
/// The grid attached with the column chooser.
/// </summary>
private SfDataGrid dataGrid;
private ObservableCollection<string> restrictedColumns;
/// <summary>
/// Initializes a new instance of the sfDataGrid
/// </summary>
/// <param name="sfDataGrid">The data grid which needs to be attached to the control.</param>
public ColumnChooserExt(SfDataGrid sfDataGrid, ObservableCollection<string> restrictedColumns) : base(sfDataGrid)
{
dataGrid = sfDataGrid;
this.restrictedColumns = restrictedColumns;
dataGrid.Columns.CollectionChanged += Columns_CollectionChanged;
}
private void Columns_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
this.CheckedListBox.DataSource = dataGrid.Columns.Where(x => !restrictedColumns.Contains(x.MappingName));
}
protected override void AddCheckedListBox()
{
base.AddCheckedListBox();
this.CheckedListBox.DataSource = dataGrid.Columns.Where(x => !restrictedColumns.Contains(x.MappingName));
}
protected override void OnSearchBoxTextChanged(object sender, EventArgs e)
{
base.OnSearchBoxTextChanged(sender, e);
List<GridColumn> searchedItems = new List<GridColumn>();
if (!string.IsNullOrEmpty(this.SearchTextBox.Text))
{
searchedItems.Clear();
searchedItems = this.dataGrid.Columns.Where(item => (item.HeaderText.ToLower().Contains(this.SearchTextBox.Text.ToLower()) && !restrictedColumns.Contains(item.MappingName))).ToList();
this.CheckedListBox.DataSource = null;
this.CheckedListBox.DataSource = searchedItems;
}
else
this.CheckedListBox.DataSource = dataGrid.Columns.Where(x => !restrictedColumns.Contains(x.MappingName));
this.CheckedListBox.Invalidate();
}
} |
I tried to adjust this example to my needs. But these not working and I don't know why.
I upgrade to .NET 4.7 and recive
System.NotImplementedException
during app start.
Hi Michal,
We have confirmed the reported scenario is a defect and logged a report for the reported scenario “System.NotImplementedException is thrown while running the SfDataGrid sample”. We will include the fix in our Weekly NuGet release which is scheduled on 29th November 2022.
You can track the status of this defect using the following feedback link:
If you have any more specification replication procedures or a scenario to be tested, you can add it as a comment in the portal.
Please let us know if you need any further assistance
Note: The provided feedback link is private, and you need to log in to view this feedback.
Sorry for the inconvenience,
We have fixed the reported issue but due to some internal issues, we are not able to include this fix in the recently released NuGet. We will include the fix in the next NuGet release which is scheduled for December 6th, 2022.
We have included the fix in our latest Weekly NuGet release v20.3.0.60 which is available for download (https://www.nuget.org/). We thank you for your support and appreciate your patience in waiting for this update. Please get in touch with us if you would require any further assistance.