This is a migrated thread and some comments may be shown as answers.

Change the AutoComplete placeholder after initialization

5 Answers 276 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Ehtesham
Top achievements
Rank 1
Ehtesham asked on 08 Oct 2013, 09:38 PM

I am setting up my AutoComplete via MVC Wrappers. On a certain event, I want to be able to change the placeholder text for this autocomplete. However, 
I am not sure where and how to set this. I've tried the following but doesn't work.
>> $('lsel_l3').data('kendoAutoComplete').options.placeholder = 'new value';

the value always shows up as "undefined" in the debugger with IE 9

The snippet below shows the setup.. Thanks in advance.

 @(Html.Kendo().AutoComplete()
                    .Name("lsel_l3")
                    .DataTextField("Name")
                    .Filter("contains")
                    .Placeholder("District")
                    .MinLength(3)
                    .HtmlAttributes(new { style = "width:250px" })
                    .DataSource(source => {
                        source.Read(read =>
                        {
                            read.Action("LocationAutoComplete", "DcmSelectors", new { area = "" })
                                                .Data(@<text>function(e) {return lsel.GetL3AutoCompleteParams(e,lsel);}</text>);
                        })
                        .ServerFiltering(true);
                    })
                        .Events(events => events.Select(@<text>function(e) {return lsel.OnL3AutoCompleteSelect(e,lsel);}</text>)
                                                                       .Change(@<text>function(e) {return lsel.OnL3AutoCompleteChange(e,lsel);}</text>))
                    )

5 Answers, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 10 Oct 2013, 04:43 AM
Hi Ehtesham,

Dynamic change of the AutoComplete's placeholder is not a supported functionality. What I can suggest you to do is to destroy the widget and reinitialize it with the new placeholder value. 

If you want to see this feature added to Kendo UI, please go to our feedback section, and post your suggestion there, so it can be taken into consideration for a future release.
 
Regards,
Kiril Nikolov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Accepted
Ehtesham
Top achievements
Rank 1
answered on 10 Oct 2013, 03:45 PM
Thanks Kiril for your response. I will certainly try that.

0
Kiril Nikolov
Telerik team
answered on 11 Oct 2013, 07:07 AM
Hi Ehtesham,

I am glad you find my answer helpful.

If you need any further assistance, please do not hesitate to contact us.
 
Regards,
Kiril Nikolov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Lennart
Top achievements
Rank 2
answered on 25 Feb 2015, 07:18 PM
Simple solution I've used in the past was to add the following:

.HtmlAttributes(new { placeholder = "Search for ..." })

0
Ehtesham
Top achievements
Rank 1
answered on 29 Sep 2015, 03:18 PM
Thanks! Lennart
Tags
AutoComplete
Asked by
Ehtesham
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Ehtesham
Top achievements
Rank 1
Lennart
Top achievements
Rank 2
Share this question
or