[PR #1315] [MERGED] Support for custom Numeric Types #2661

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

📋 Pull Request Information

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

Base: masterHead: feature/convertvalue-test-customtype


📝 Commits (5)

  • e2797b8 add a test for the ConvertValue Parameter. Update InternalValueChanged code with the following enhancements:
  • 9183f87 move dollars to own file, and implement IComparable, and a TypeConverter
  • 3ae944a Support TypeConverter for conversions to/from decimal, for custom numeric types
  • c223dfb support for IComparable, for when Min/Max are used with custom numeric types
  • c8de00f move Max/Min null check inside CheckBounds

📊 Changes

3 files changed (+195 additions, -21 deletions)

View changed files

Radzen.Blazor.Tests/Dollars.cs (+58 -0)
📝 Radzen.Blazor.Tests/NumericTests.cs (+70 -0)
📝 Radzen.Blazor/RadzenNumeric.razor.cs (+67 -21)

📄 Description

In my project, we have various custom numeric types, like Money, Point, etc, that we would like to use with RadzenNumeric.
RadzenNumeric's support for these kind of types is problematic, as it uses Convert.ChangeType behind the scenes, such that it only works with primitive types.

This adds support for custom numeric types by:

  1. Adding TypeConverter support to/from decimal for TValue
  2. Adding support for IComparable<decimal>, in the case the type implements it
  3. Update flow of InternalValueChanged to remove unnecessary ChangeValue conversion attempts. This allows limited support for custom numeric types, even if they don't have a TypeConverter (as long as ConvertValue is set)

This would really be a great help!


🔄 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/1315 **Author:** [@pianomanjh](https://github.com/pianomanjh) **Created:** 1/10/2024 **Status:** ✅ Merged **Merged:** 1/10/2024 **Merged by:** [@enchev](https://github.com/enchev) **Base:** `master` ← **Head:** `feature/convertvalue-test-customtype` --- ### 📝 Commits (5) - [`e2797b8`](https://github.com/radzenhq/radzen-blazor/commit/e2797b815532542f36126c67dfbfb716db42f7f8) add a test for the ConvertValue Parameter. Update InternalValueChanged code with the following enhancements: - [`9183f87`](https://github.com/radzenhq/radzen-blazor/commit/9183f87a92d351615ee7712c616cf7f154d53efa) move dollars to own file, and implement IComparable<decimal>, and a TypeConverter - [`3ae944a`](https://github.com/radzenhq/radzen-blazor/commit/3ae944a49e9d842b568c908eeb88afa349a74930) Support TypeConverter for conversions to/from decimal, for custom numeric types - [`c223dfb`](https://github.com/radzenhq/radzen-blazor/commit/c223dfb8de3265c39625dd98df9d70bac9a2fefa) support for IComparable, for when Min/Max are used with custom numeric types - [`c8de00f`](https://github.com/radzenhq/radzen-blazor/commit/c8de00f0f4062ee55f55f3519ec51c5c92668bbd) move Max/Min null check inside CheckBounds ### 📊 Changes **3 files changed** (+195 additions, -21 deletions) <details> <summary>View changed files</summary> ➕ `Radzen.Blazor.Tests/Dollars.cs` (+58 -0) 📝 `Radzen.Blazor.Tests/NumericTests.cs` (+70 -0) 📝 `Radzen.Blazor/RadzenNumeric.razor.cs` (+67 -21) </details> ### 📄 Description In my project, we have various custom numeric types, like `Money`, `Point`, etc, that we would like to use with RadzenNumeric. RadzenNumeric's support for these kind of types is problematic, as it uses `Convert.ChangeType` behind the scenes, such that it only works with primitive types. This adds support for custom numeric types by: 1. Adding `TypeConverter` support to/from decimal for TValue 2. Adding support for `IComparable<decimal>`, in the case the type implements it 3. Update flow of `InternalValueChanged` to remove unnecessary ChangeValue conversion attempts. This allows limited support for custom numeric types, even if they don't have a TypeConverter (as long as `ConvertValue` is set) This would really be a great help! --- <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:52 +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#2661