Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HideColumnsByName parameter to handle GenerateColumns hide some column #3863

Merged
merged 3 commits into from
May 22, 2024

Conversation

dessli
Copy link
Contributor

@dessli dessli commented May 14, 2024

…olumn

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • Component style update
  • Bundle size optimization
  • Performance optimization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

💡 Background and solution

Many times, automatically generated columns need to hide certain class fields. By passing an array of field names through HideColumnByName, these fields can be easily hidden.

📝 Changelog

Language Changelog
🇺🇸 English
🇨🇳 Chinese

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Changelog is provided or not needed

Copy link

github-actions bot commented May 14, 2024

@dessli dessli changed the title add HideColumnsByName parameter to handle GenerateColumns hide some column Add HideColumnsByName parameter to handle GenerateColumns hide some column May 14, 2024
@ElderJames
Copy link
Member

Thanks for contribution @dessli , have you tested dynamic hiding/display columns? Because column itself has a Hidden parameter, you can use Definitions to specify which column is hidden.

@dessli
Copy link
Contributor Author

dessli commented May 15, 2024

Thanks for contribution @dessli ,have you tested dynamic hiding/display columns? Because column itself has a Hidden parameter, you can use Definitions to specify which column is hidden.

Hello @ElderJames , yes, I have tried Definitions, something like this:

<GenerateColumns Range="1.." Definitions="HideColumn"/>

public void HideColumn(string columnName, object columnObject)
{
	var hideColumnList = new List<string> { "IdCard", "Phone" };
	if (!hideColumnList.Contains(columnName)) return;
	var type = columnObject.GetType();
	var baseType = type.BaseType;
	var property = baseType?.GetProperty("Hidden");
	if (property != null)
	{
		property.SetValue(columnObject, true);
	}
}

But I think having a parameter like HideColumnsByName would be more convenient.🤔

ElderJames
ElderJames previously approved these changes May 16, 2024
@ElderJames
Copy link
Member

All right, please add the new parameter to the API doc.

@ElderJames ElderJames merged commit 59a6614 into ant-design-blazor:master May 22, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants