C1-multi-auto-complete not showing already selected items

Posted by: sebastian73 on 13 June 2021, 11:11 pm EST

    • Post Options:
    • Link

    Posted 13 June 2021, 11:11 pm EST

    Hello!!

    I’m working on a form to modify already loaded data, and I can’t get the c1-multi-auto-complete to load the data, it always shows as none item selected.

    My model has a property with an array of IDs and list of objects with data:

    
    public SelectList Transportes { get; set; } //data
    public long[] TransportesSeleccionados { get; set; } //list of IDs
    
    

    My code in view:

    
    @{
    var transportesSeleccionadosModificar = Model.Transportes.Where(t => Model.TransportesSeleccionados.Contains(long.Parse(t.Value)));
    }
    
    <c1-multi-auto-complete for="TransportesSeleccionados" 
                                            selected-values="transportesSeleccionadosModificar"
                                            display-member-path="Text" 
                                            selected-value-path="Value" 
                                            css-match="highlight" class="form-control">
                        <c1-items-source source-collection="Model.Transportes"></c1-items-source>
                    </c1-multi-auto-complete>
    
    

    Any suggestion on what I’m doing wrong?

    Thanks in advance!

  • Posted 16 June 2021, 9:10 pm EST

    Hi,

    We are sorry for the inconvenience. We are able to replicate the issue at our end. The issue is with the provided values to selected-values properties.

    For assigning the values to selected-values, it should be list of objects containing the values.

    Please refer to the following code snippet for reference:

    @model IEnumerable<DataItem>
    @{
        ViewData["Title"] = "Home Page";
        object[] ids = new object[] { 0, 3, 6 }; // Ids to be selected as default
    }
    <c1-multi-auto-complete id="mCtrl" selected-values="ids" selected-value-path="ID" display-member-path="Country">
        <c1-items-source source-collection="Model"></c1-items-source>
    </c1-multi-auto-complete>
    

    Hope it helps!

    Regards,

    Manish Gupta

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels