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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Thread ID:

Created:

Updated:

Platform:

Replies:

148867 Nov 6,2019 05:35 PM UTC Nov 7,2019 10:48 AM UTC Blazor 1
loading
Tags: MultiSelect Dropdown
Yuriy Shkraba
Asked On November 6, 2019 05:35 PM UTC

 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;

        }}

Narayanasamy Panneer Selvam [Syncfusion]
Replied On 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.
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon