Trying to use TelerikEditor OnChange="@SomeMethod"

3 Answers 746 Views
Editor
Roland
Top achievements
Rank 3
Iron
Iron
Veteran
Roland asked on 21 Sep 2021, 12:33 AM

No matter what method signature I come up with, I always get a compile error like 

[CS1503] Argument 3: cannot convert from 'method group' to 'bool'

I tried void SomeMethod(), void SomeMethod(object _), Task SomeMethod(), Task SomeMethod(object _), async Task ...

I also tried <TelerikEditor OnChange="@(_ => SomeMethod())"> and variations thereof.

Trying to use <TelerikEditor T="string" > does not work either.

Any idea what I should be doing?

3 Answers, 1 is accepted

Sort by
1
Accepted
Nadezhda Tacheva
Telerik team
answered on 23 Sep 2021, 03:13 PM

Hello Roland,

The reason behind this is that the Editor does not expose OnChange event - you can check the available events in the article that Nikolas linked - Editor Events.

While the OnChange event is not something that the Editor supports (in Blazor and in other suites), exposing an OnBlur event seems like a valid enhancement. Therefore, I opened a feature request on your behalf in our public feedback portal - OnBlur event.

I have added your vote to increase its popularity as we are prioritizing the feature requests implementation based on the community interest and demand. As I opened the request on your behalf, you are subscribed and will receive email notifications when its status changes.

In the meantime, since you mentioned you want to convert the HTML to RTF on explicit demand, apart from on events like OnChange and OnBlur, how would you consider one of the following options to execute that logic:

  • Add a Telerik Button outside of the Editor - could be applicable depending on the application design.

  • Add a custom Editor Tool - basically a TelerikButton that will be added in the Editor's toolbar - you can find details on how to do it in this article.

You may handle the OnClick event of the button in both cases to perform your desired business logic.

I hope you will find this useful. If any further questions appear, please let us know.

Regards,


Nadezhda Tacheva
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Roland
Top achievements
Rank 3
Iron
Iron
Veteran
commented on 24 Sep 2021, 06:27 PM | edited

>The reason behind this is that the Editor does not expose OnChange event
Rider intellisense suggests OnChange and OnBlur because the base class TelerikInputBase supports it. I did not verify it in the API reference. 

>you want to convert the HTML to RTF on explicit demand
Yes, but in code, not by a user, so no buttons needed, just an event (handler)

I'll just wait for the OnBlur implementation.
I have my own <HtmlEditor> wrapper, and that one exposes the sanitized content, so whenever I want I can have the latest content without an explicit Save or Blur event. Good enough.

Nadezhda Tacheva
Telerik team
commented on 27 Sep 2021, 03:59 PM

Hi Roland,

I am glad to find out this will suffice for your use case. Please let us know if you run across any other concerns, so we can step in and assist.

0
Nikolas
Top achievements
Rank 2
Iron
Iron
answered on 21 Sep 2021, 06:46 AM

Hello Roland,

Did you try with ValueChanged?

<TelerikEditor ValueChanged="ValueChangedHandler">

</TelerikEditor>
@code {
    void ValueChangedHandler(string value)
    {
        
        Console.WriteLine("ValueChanged fired");
    }
}


Docs: https://docs.telerik.com/blazor-ui/components/editor/events

Regards,
Nikolas

0
Roland
Top achievements
Rank 3
Iron
Iron
Veteran
answered on 21 Sep 2021, 01:20 PM
That event fires with every keypress and I need to convert the HTML to RTF. I only want to do that on explicit demand, or occasionally on events like OnChange and OnBlur.
Tags
Editor
Asked by
Roland
Top achievements
Rank 3
Iron
Iron
Veteran
Answers by
Nadezhda Tacheva
Telerik team
Nikolas
Top achievements
Rank 2
Iron
Iron
Roland
Top achievements
Rank 3
Iron
Iron
Veteran
Share this question
or