Code Monkey home page Code Monkey logo

Comments (7)

vnbaaij avatar vnbaaij commented on July 25, 2024

With the autocomplete, we control the rendering of the 'list'. That is why we can do the virtualization. For the combobox the list comes from the web component. We can't get in that render process. @dvoituron correct?

from fluentui-blazor.

dvoituron avatar dvoituron commented on July 25, 2024

Yes. Exactly.

If you have a large list of items, ˋFluentAutocompleteˋ would be better.

from fluentui-blazor.

MarvinKlein1508 avatar MarvinKlein1508 commented on July 25, 2024

Hey @vnbaaij & @dvoituron thanks for your input on this topic! :)

My problem with the FluentAutocomplete component is the extra amount of work which is required in order to get a 1:1 realtionship. Although the component exposes @bind-SelectedOption this option is not supported. In order to get it working for just 1 item all of this is necessary:

  1. Set MaximumSelectedOptions="1"
  2. Define an IEnenumerable as a property
  3. Bind @bind-SelectedOptions to an IEnumerable
  4. Bind @bind-SelectedOptions:after and do manual mapping
  5. On pageload the TOption from your actual model needs be assigned to your IEnumerable of step 2.

Or when we talk in code:

@code {
    private IEnumerable<Country> CountryAutocomplete { get; set; } = [];
    
    // Assume MyInput contains Country and CountryId
    public MyInput? Input { get; set; } 
    protected override async Task OnInitializedAsync()
    {

        Input = await GetInputAsync(); 
        if (Input is not null)
        {
            if(Input.Country is not null)
            {
                CountryAutocomplete = [Input.Country];
            }
        }
    }

    private void OnCountryChanged()
    {
        if (Input is null)
        {
            return;
        }

        var _country = KostenstelleAutocomplete.FirstOrDefault();
        
        Input.Country = _country;
        Input.CountryId = _country?.CountryId;   
    }
}

It would be great if this process would be as easy as with the FluentCombobox where I only need to bind to the actual property of my object.

from fluentui-blazor.

MarvinKlein1508 avatar MarvinKlein1508 commented on July 25, 2024

Also aren't the options rendered here?

private void RenderOptions(RenderTreeBuilder __builder)

from fluentui-blazor.

vnbaaij avatar vnbaaij commented on July 25, 2024

It's not about the rendering of the options, it is about the list the options are rendered in.

from fluentui-blazor.

dvoituron avatar dvoituron commented on July 25, 2024

You can find an example of using Autocomplete with 1 item on this page, section "Culture"

https://www.fluentui-blazor.net/DateTime

from fluentui-blazor.

MarvinKlein1508 avatar MarvinKlein1508 commented on July 25, 2024

@dvoituron yes as you can see it's quite hard to do. Now throw a new object instance from the database into the pot as well and it will drive you crazy! :)

from fluentui-blazor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.