Irresponsive UI when wrapped in a custom object

Guys...as always, thanks for the prompt response...this is one of the key reasons, I stay w/ Radzen. :slight_smile:

Here's the declaration that I wrap within my custom componet:

<RadzenDropDown
  class         ="align-middle"
  id            ="cousr_dd" 
  AllowClear    ="true"
  SelectedItemChanged        ="OnChange"
  Data          ="@Presenter?.Users"
  Multiple      ="false"
  Placeholder   ="@Placeholder"
  TextProperty  ="COUser.FirstName COUser.LastName"
  TValue        ="COUser"
  ValueProperty ="COUser.Login">
</RadzenDropDown>

Here's the implementation on

void OnChange(object o)
  {
    if (o is null)
    {
      Presenter?.ClearSelection();
    }
    else
    {
      Presenter?.SelectUser(o as COUser);
    }
    //if I leave this here, the UI becomes irresponsive.
    //StateHasChanged();
  }

I am afraid we don't understand what the problem is. We don't know what Presenter is and how your component is used. We also don't have the implementation of your custom component (and even if we did we don't debug custom components). Honestly the best suggestion I have is to attach the source code of Radzen.Blazor to your application and check with the debugger what triggers the OnChange event endlessly.

found the problem! :slight_smile:
The hard coded id property messed things up.

@korchev please excuse my ignorance. I still have so much to learn about Blazor/Razor programming.
Would you mind shedding some light as I how I can pass the "id" value from my custom object to the embedded Razden component?
as always...thank you so much for your and your teams' help.

You can use a Parameter property.

<MyComponent Id="some-unique-id" />

MyComponent.razor:

<RadzenDropDown id=@Id ... />
@code {
   [Parameter]
   public string Id { get; set; }
}
1 Like