Change event doesn't raise on bound value changed #195

Closed
opened 2026-01-29 17:33:10 +00:00 by claunia · 1 comment
Owner

Originally created by @javiercampos on GitHub (Sep 8, 2021).

Describe the bug
The Change event on form components (at least RadzenNumeric and RadzenDateTimePicker) doesn't change when a bound value changes, which is what I'd expect. It only raises when changing something from the UI itself.

To Reproduce

<RadzenNumeric @bind-Value="@Something" Change="@DoSomething" />
<RadzenButton Click="@ChangeSomething" />
@code {
  int? Something { get; set; }
  void DoSomething(int? value) {
     // Do something
  }
  void ChangeSomething() {
    Something = 1;
  }
}

Expected behavior
I'd expect DoSomething to be called when the bound value changes (as if I was subscribing to the eventcallback OnValueChanged, which I can't, because that's used by the binding).

Knowing that @bind-Value does make a handler for ValueChanged and you can't use that to also fire OnChange, I'm unsure of a possible solution to this at the component level

I understand that for the example as a workaround, I could just make the setter of Something call DoSomething, or ditch the @bind-Value syntax and use Value="@Something" ValueChanged="@ChangeSomething" where ChangeSomething changes the property and does whatever I want... however if there's anything that could be done at the component level (I honestly don't know what), it'd be great.

Originally created by @javiercampos on GitHub (Sep 8, 2021). **Describe the bug** The `Change` event on form components (at least `RadzenNumeric` and `RadzenDateTimePicker`) doesn't change when a bound value changes, which is what I'd expect. It only raises when changing something from the UI itself. **To Reproduce** ```razor <RadzenNumeric @bind-Value="@Something" Change="@DoSomething" /> <RadzenButton Click="@ChangeSomething" /> @code { int? Something { get; set; } void DoSomething(int? value) { // Do something } void ChangeSomething() { Something = 1; } } ``` **Expected behavior** I'd expect `DoSomething` to be called when the bound value changes (as if I was subscribing to the eventcallback `OnValueChanged`, which I can't, because that's used by the binding). Knowing that `@bind-Value` does make a handler for `ValueChanged` and you can't use that to also fire `OnChange`, I'm unsure of a possible solution to this at the component level I understand that for the example as a workaround, I could just make the setter of `Something` call `DoSomething`, or ditch the `@bind-Value` syntax and use `Value="@Something" ValueChanged="@ChangeSomething"` where `ChangeSomething` changes the property and does whatever I want... however if there's anything that could be done at the component level (I honestly don't know what), it'd be great.
Author
Owner

@enchev commented on GitHub (Sep 9, 2021):

Hey @javiercampos,

Change event will be raised when you interact with the component, not when you change the bound value outside.

@enchev commented on GitHub (Sep 9, 2021): Hey @javiercampos, Change event will be raised when you interact with the component, not when you change the bound value outside.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#195