We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

No elements in the dropdown when try to add @bind-Value

 Hello, I need to implement MultiSelect with templates. Everything work but when I try to add @bind-Value="@Tags" to the code the dropdown is blank.  I tried to implement custom CustomAdaptor and mock data inside this class but does not help me. Please help me resolve this an issue. 
<EjsMultiSelect TValue="string[]" @bind-Value="@Tags" ModelType="@Model" Placeholder="Select a customer" DataSource="@Data1">
                    <MultiSelectTemplates>
                        <ItemTemplate>
                            <span class='item'>
                                <span class='name'>@((context as Tag).Name)</span>
                                <span class='value'>@((context as Tag).Value)</span>
                            </span>
                        </ItemTemplate>
                        <HeaderTemplate>
                            <span class='head'>
                                <span class='name'>Name</span>
                                <span class='value'>Value</span>
                            </span>
                        </HeaderTemplate>
                    </MultiSelectTemplates>
                    <MultiSelectEvents TValue="string[]" ValueChange="OnChange"></MultiSelectEvents>
                    <EjsDataManager AdaptorInstance="@typeof(CustomAdaptor)" Adaptor="Adaptors.CustomAdaptor" CrossDomain=true></EjsDataManager>
                    <MultiSelectFieldSettings Value="Value" Text="Name"></MultiSelectFieldSettings>
                </EjsMultiSelect>


//--------------------------------------------------------------------
public class Tag
    {
      
        public string Name { get; set; }
       
        public string Value { get; set; }
    }

 public string[] Tags = new string[] { };
//---------------------------------------------------------------------
 protected async Task OnChange(MultiSelectChangeEventArgs<string[]> args)
        {
            Tags = args.Value;
           
            StateHasChanged();
        }
//---------------------------------------------------------------
protected override async Task OnInitializedAsync()
        {
      
            Tags = new string[]{ "TagValue1" };
      
        }

//---------------------my data-------------------------
        public List<Tag> Data1 = new List<Tag>()
        {
            new Tag()
            {
                Name = "TagName1",
                Value = "TagValue1"
            },
            new Tag()
            {
                Name = "TagName2",
                Value = "TagValue2"
            },
            new Tag()
            {
                Name = "TagName3",
                Value = "TagValue3"
            }
        };

        public Tag Model = new Tag();

    }
//----------------------------------------------------
 public class CustomAdaptor : DataAdaptor
    {

        public static List<Tag> order = new List<Tag>()
        {
            new Tag()
            {
                Name = "TagName1",
                Value = "TagValue1"
            },
            new Tag()
            {
                Name = "TagName2",
                Value = "TagValue2"
            },
            new Tag()
            {
                Name = "TagName3",
                Value = "TagValue3"
            }
        };

        public override object Read(DataManagerRequest dm, string key = null)
        {
            
            IEnumerable<Tag> dataSource = order;
            if (dm.Search != null && dm.Search.Count > 0)
            {
                dataSource = DataOperations.PerformSearching(dataSource, dm.Search);  //Search
            }
            if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting
            {
                dataSource = DataOperations.PerformSorting(dataSource, dm.Sorted);
            }
            if (dm.Where != null && dm.Where.Count > 0) //Filtering
            {
                dataSource = DataOperations.PerformFiltering(dataSource, dm.Where, dm.Where[0].Operator);
            }
            int count = dataSource.Cast<Tag>().Count();

            if (dm.Skip != 0)
            {
                dataSource = DataOperations.PerformSkip(dataSource, dm.Skip);         //Paging
            }
            if (dm.Take != 0)
            {
                dataSource = DataOperations.PerformTake(dataSource, dm.Take);
            }

            if (dm.Where != null && dm.Where.Count > 0) //Filtering
            {

                dataSource = DataOperations.PerformTake(dataSource, 1);

            }

            return dm.RequiresCounts ? new DataResult() { Result = dataSource, Count = count } : (object)dataSource;

        }}

1 Reply

NP Narayanasamy Panneer Selvam Syncfusion Team November 7, 2019 10:48 AM UTC

Hi Yuriy,

Good day to you.

 
We have validated your problem from the code you have provided. We were able to reproduce your issue. We have logged this as defect from our end. Fix for this issue will be included with our upcoming weekly patch release. We appreciate your patience until then.

 
Now, you can track status from the below feedback link: https://www.syncfusion.com/feedback/10010/


Regards,
Narayanasamy P.
 


Loader.
Live Chat Icon For mobile
Up arrow icon