AutoGeneratingColumn event
Hello.
I want the user to be able to choose the columns they want displayed so I'm using the ChooseColumnPopup to show the available columns. I've attached an event to the Ok button and save the selected columns. Using the AutoGeneratingColumn event to cancel any column not in the selected columns seems to work just fine. But if I show the ChooseColumnPopup again, the columns I cancelled are not in the list.
There has to be a better approach to this problem. Any ideas?
Thank you
Of course after I post this, I had an idea.
This is what I was using:
e.Cancel = !(DAC.Configuration.SelectedColumns.Contains($"[{e.Column.MappingName}]"));
So I thought about just making it not visible
e.Column.Visible = DAC.Configuration.SelectedColumns.Contains($"[{e.Column.MappingName}]");
That seemed to have made it work. Still would be interested if there is a better approach.
Thank you
Based on the information provided, we understand that you are displaying the `ColumnChooserPopup` to select items and attempting to display them, while canceling the generation of columns for unselected items in the `AutoGeneratingColumn` event. However, upon reopening the popup, the items are not displayed.
sfDataGrid1.DataSource = collections.Orders; columnChooserPopup = new ColumnChooserPopup(this.sfDataGrid1); columnChooserPopup.Show(); this.sfDataGrid1.Columns[0].Visible = false; this.sfDataGrid1.Columns[1].Visible = false; |
Malini Selvarasu
Hi Malini - Thank you for your response and confirming I need to hide the columns instead of cancelling them. I appreciate your help!
We are glad to hear that your requirement has been fulfilled. Hence, we are closing this forum. Please feel free to reach out to us if you need further assistance. We are always happy to help.
- 4 Replies
- 2 Participants
-
DZ David Zangger
- Jan 18, 2025 08:50 PM UTC
- Jan 21, 2025 06:41 AM UTC