Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration: Pass Chart elements by ref / ElementReference (not by id) to JSInterop #42

Closed
SeppPenner opened this issue Sep 30, 2019 · 1 comment
Labels
from migration These issues were migrated from Joelius300s repository and more information can be found there wontfix This will not be worked on

Comments

@SeppPenner
Copy link
Contributor

Migrated from Joelius300/ChartJSBlazor#76:

Describe the feature request

It would be a good idea to use the ElementReference type to reference the charts from C# to JS. Example (Although it's a bit outdated): https://visualstudiomagazine.com/blogs/tool-tracker/2018/11/an-ad-hoc-approach.aspx

Which charts does this feature request apply to?

All.

Describe the solution you'd like

Like in the example:

Razor:

<input type="text" ref="mytextbox" value="Peter" />

@code
{
    ElementReference mytextbox;

    protected override Task OnInitializedAsync()
    {
        await JSRuntime.Current.InvokeAsync<string>("SetName", mytextbox);
    }
}

Javascript:

function SetName(textbox) {
    textbox.value = "Vogel";
}

Describe alternatives you've considered

None.

Additional context

Example: https://visualstudiomagazine.com/blogs/tool-tracker/2018/11/an-ad-hoc-approach.aspx.

@Joelius300 Joelius300 added the from migration These issues were migrated from Joelius300s repository and more information can be found there label Nov 14, 2019
@Joelius300
Copy link
Contributor

Thank you but I'm going to close this as wontfix. I generally like the idea but I have 1.5 reasons to decline this:

  • We're working with a weird setup of double json serialization at the moment because we still can't pass serializer options to IJSRuntime. These reference objects exist both in C# and in JavaScript and in order for them to behave correctly, they need to be passed through the serializer along with a special converter which is registed when using any JSRuntime. Since we mangle the object to an ExpandoObject before it even reaches that serializer, the reference won't work.
  • The current way works great and from a performance standpoint I don't think you'll ever see a difference.

In other words: it would require extra attention to make it work and the current solution has no known downsides.

@Joelius300 Joelius300 added the wontfix This will not be worked on label Nov 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
from migration These issues were migrated from Joelius300s repository and more information can be found there wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants