How to Retrieve Text value from C1AutoComplete

Posted by: eeklund on 5 November 2022, 3:06 am EST

    • Post Options:
    • Link

    Posted 5 November 2022, 3:06 am EST

    I am new to blazor and I am trying to create a search form using C1AutoComplete for text input.

    <C1AutoComplete @bind-SelectedItem=“@AppRightsSearchCriteria.Application” ItemsSource=“Applications” AutoComplete=“true” T=“Application” />

    I am able to bind the selected item but I am looking to also get the text in case where they type a value that is not in the ItemSource.

    I can bind one way with the text property but I can’t seem to get the text property after they have entered a new value.

  • Posted 9 November 2022, 8:04 pm EST

    Hi,

    We are sorry for the inconvenience, currently, there is no property such as @bind-Text to update the text as the Text Changes for the Control.

    We have raised an enhancement request for this with the internal tracking id C1-5227.

    Alternatively, you may use some event that can be used to fetch the updated Text when required for e.g. some other Control focus event.

    AutoComplete.Text property.

    Regards.

    Manish Gupta

  • Posted 10 November 2022, 5:07 am EST

    Thank you for your response. I am not fully understanding your direction. Can you give me a mocked up example?

  • Posted 10 November 2022, 4:41 pm EST

    Hi,

    Please refer to the following code snippet for reference:

    
    <C1AutoComplete @ref="AutoComplete" T="Test" ItemsSource="Tests" ValueMemberPath="Prop1" DisplayMemberPath="Prop2" Placeholder="Please Select" Text="@Val" Filtering="FilteringSource"></C1AutoComplete>
    
    <p>AutoComplete Text :  @Val</p>
    
    
    @code{
    
        public C1AutoComplete<Test> AutoComplete = null;
        public string Val = "";
        public List<Test> Tests { get; set; } = MData.GetData();
        public class Test
        {
            public string Prop1 { get; set; }
            public string Prop2 { get; set; }
        }
       
        public void FilteringSource (object sender, AutoCompleteFilteringEventArgs args)
        {
            Val = args.FilterString;
            StateHasChanged();
        }
    }

    Hope it clears!

    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