Autocomplete overlapping when being loaded by dropdownlist change event

2 posts, 1 answers
  1. Chris
    Chris avatar
    3 posts
    Member since:
    Sep 2017

    Posted 24 Sep 2017 Link to this post

    I have an AutoComplete being populated when I select a value from a dropdownlist. Its fine the first time I select a value from a dropdownlist, but when I change my mind and select a different value the AutoComplete overlaps itself, and then gets a blue border..How do I stop the Autocomplete from overlapping itself, when I select a different value from the dropdownlist?


    Here is the code


    <!DOCTYPE html>
      <meta charset="utf-8">
      <div class="container">
      <div class="form-horizontal">
        <div class="row">
          <div class="col-md-5">
            <div class="form-group">
              <input id="txtState" />
        </div><!-- End txtState -->
        <div class="row">
          <div class="col-md-5">
            <div class="form-group">
              <input id="txtCounty" />
        </div><!-- End txtState -->
      </div><!-- End form horizontal -->
            var stateData = [
          {"StateID" : 1, "StateName": "Oklahoma"},
          {"StateID" : 2, "StateName": "Texas"}
      function LoadStates(stateData){
            var countyData1 = [
          {"CountyID" : 1, "CountyName": "CountyA"},
          {"CountyID" : 2, "CountyName": "CountyB"},
          {"CountyID" : 3, "CountyName": "CountyC"},
          {"CountyID" : 4, "CountyName": "CountyD"}
        var countyData2 = [
          {"CountyID" : 5, "CountyName": "CountyE"},
          {"CountyID" : 6, "CountyName": "CountyF"},
          {"CountyID" : 7, "CountyName": "CountyG"},
          {"CountyID" : 8, "CountyName": "CountyH"}
                dataSource: stateData,
                index: 0,
                dataTextField: "StateName",
                dataValueField: "StateID",
                animation: false,
                optionLabel: "State",
                change: function (e) {
                    var dataItem = e.sender.dataItem();
                    if(dataItem.StateID === 1){
      function LoadCounty(countyData){
                dataSource: countyData,
                dataTextField: "CountyName",
                dataValueField: "CountyID",
                filter: "startswith",
                placeholder: "Type County...",
                select: function (e) {
                    var DataItem = this.dataItem(e.item.index());
                    currentSelectedItem = DataItem.CountyID;



  2. Answer
    Neli avatar
    194 posts

    Posted 25 Sep 2017 Link to this post

    Hello Chris,

    Attached you may find a Dojo example where an AutoComplete widget is populated based on the data selected in a DropDownList. 

    In order to have only one instance of the AutoComplete, the initialization of the widget is extracted outside of the LoadCounty method. In the method the AutoComplete widget is referenced and the dataSource is set using the setDataSource method.

    function LoadCounty(countyData){
        var autocomplete = $("#txtCounty").data("kendoAutoComplete");      

    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top