Change the AutoComplete placeholder after initialization

6 posts, 1 answers
  1. Ehtesham
    Ehtesham avatar
    8 posts
    Member since:
    Apr 2013

    Posted 08 Oct 2013 Link to this post


    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>))
                        )
  2. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2564 posts

    Posted 09 Oct 2013 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. Answer
    Ehtesham
    Ehtesham avatar
    8 posts
    Member since:
    Apr 2013

    Posted 10 Oct 2013 Link to this post

    Thanks Kiril for your response. I will certainly try that.

  5. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2564 posts

    Posted 11 Oct 2013 Link to this post

    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!
  6. Lennart
    Lennart avatar
    4 posts
    Member since:
    Aug 2012

    Posted 25 Feb 2015 Link to this post

    Simple solution I've used in the past was to add the following:

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

  7. Ehtesham
    Ehtesham avatar
    8 posts
    Member since:
    Apr 2013

    Posted 29 Sep 2015 Link to this post

    Thanks! Lennart
Back to Top
Kendo UI is VS 2017 Ready