[PR #1318] [MERGED] Support for IFormattable #2666

Open
opened 2026-01-29 18:19:54 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/radzenhq/radzen-blazor/pull/1318
Author: @pianomanjh
Created: 1/10/2024
Status: Merged
Merged: 1/12/2024
Merged by: @enchev

Base: masterHead: feature/numeric-support-for-iformattable


📝 Commits (8)

  • e0f7a35 Support IFormattable, if TValue implements it
  • 11a0c62 Include demo for custom numeric types
  • 0364a9a improve method name
  • 0809415 In cases where the value is already of the correct type, do not perform conversion. Refactor SetParametersAsync to honor custom numeric support
  • a85a6c3 perform the Min/Max check before the equality shortcut
  • 06afa16 remove unnecessary type conversion logic
  • 993199b fixup: if type implements IComparable, be sure to return value immediately, if in range
  • 44256dc PR feedback: this resolves the issue, in that the value is pushed to the dom via JS. I couldn't understand why this existing statement had the other conditionals. Why would you want to trigger the ValueChanged/Changed callbacks, if the value indeed hasn't changed, or if there's a Format. However, admittedly I don't know the background of why it was this way.

📊 Changes

7 files changed (+203 additions, -20 deletions)

View changed files

📝 Radzen.Blazor.Tests/NumericTests.cs (+19 -0)
Radzen.Blazor.Tests/Temperature.cs (+35 -0)
📝 Radzen.Blazor/RadzenNumeric.razor.cs (+21 -20)
RadzenBlazorDemos/Models/Dollars.cs (+58 -0)
RadzenBlazorDemos/Models/Temperature.cs (+35 -0)
RadzenBlazorDemos/Pages/NumericCustomType.razor (+25 -0)
📝 RadzenBlazorDemos/Pages/NumericPage.razor (+10 -0)

📄 Description

  • As a follow-up to PR #1315 , to add support for IFormattable, for scenarios where custom numeric types would like to handle their own formatting.
  • Adjusts the code in SetParametersAsync to also support custom numeric types, and provides a fast path to avoid conversion if the value to be set is already of the correct type.
  • Provides demo examples of using custom numeric types with RadzenNumeric.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/radzenhq/radzen-blazor/pull/1318 **Author:** [@pianomanjh](https://github.com/pianomanjh) **Created:** 1/10/2024 **Status:** ✅ Merged **Merged:** 1/12/2024 **Merged by:** [@enchev](https://github.com/enchev) **Base:** `master` ← **Head:** `feature/numeric-support-for-iformattable` --- ### 📝 Commits (8) - [`e0f7a35`](https://github.com/radzenhq/radzen-blazor/commit/e0f7a35a1e3bca5991ce5bb1ebd63be53b90bb4d) Support IFormattable, if TValue implements it - [`11a0c62`](https://github.com/radzenhq/radzen-blazor/commit/11a0c623e2028c009de92e8e0d9f6056d28ca44f) Include demo for custom numeric types - [`0364a9a`](https://github.com/radzenhq/radzen-blazor/commit/0364a9ac8d6d96e6a2a6d67f0f3079e13dafe2e8) improve method name - [`0809415`](https://github.com/radzenhq/radzen-blazor/commit/0809415dcfe50ce2433d8bfde5f791c7f874d7e3) In cases where the value is already of the correct type, do not perform conversion. Refactor SetParametersAsync to honor custom numeric support - [`a85a6c3`](https://github.com/radzenhq/radzen-blazor/commit/a85a6c35fa2bd006e00c6b3a14f4f79d12f37de9) perform the Min/Max check before the equality shortcut - [`06afa16`](https://github.com/radzenhq/radzen-blazor/commit/06afa16048aa976ae14c9a1e8972a7e07237ed6f) remove unnecessary type conversion logic - [`993199b`](https://github.com/radzenhq/radzen-blazor/commit/993199b649a26a7c9cd8fb30462b8e782cfacbf8) fixup: if type implements IComparable, be sure to return value immediately, if in range - [`44256dc`](https://github.com/radzenhq/radzen-blazor/commit/44256dc0bb9cf2ab2b557de0b716a0db4e8772e2) PR feedback: this resolves the issue, in that the value is pushed to the dom via JS. I couldn't understand why this existing statement had the other conditionals. Why would you want to trigger the ValueChanged/Changed callbacks, if the value indeed hasn't changed, or if there's a Format. However, admittedly I don't know the background of why it was this way. ### 📊 Changes **7 files changed** (+203 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `Radzen.Blazor.Tests/NumericTests.cs` (+19 -0) ➕ `Radzen.Blazor.Tests/Temperature.cs` (+35 -0) 📝 `Radzen.Blazor/RadzenNumeric.razor.cs` (+21 -20) ➕ `RadzenBlazorDemos/Models/Dollars.cs` (+58 -0) ➕ `RadzenBlazorDemos/Models/Temperature.cs` (+35 -0) ➕ `RadzenBlazorDemos/Pages/NumericCustomType.razor` (+25 -0) 📝 `RadzenBlazorDemos/Pages/NumericPage.razor` (+10 -0) </details> ### 📄 Description - As a follow-up to PR #1315 , to add support for `IFormattable`, for scenarios where custom numeric types would like to handle their own formatting. - Adjusts the code in `SetParametersAsync` to also support custom numeric types, and provides a fast path to avoid conversion if the value to be set is already of the correct type. - Provides demo examples of using custom numeric types with `RadzenNumeric`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 18:19:54 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#2666