Restrict User Input when using AutoComplete inside the Grid

2 posts, 0 answers
  1. Oren
    Oren avatar
    2 posts
    Member since:
    May 2016

    Posted 10 Jun Link to this post

    Hello,

    I am trying to restrict user input of the AutoComplete but the AutoComplete is inside a Kendo UI (MVC) Grid. I successfully implemented the example showing how to restrict user input of an AutoComplete but it does not keep the value cleared when the AutoComplete is inside a Grid. This is the example that I followed: http://docs.telerik.com/kendo-ui/controls/editors/autocomplete/how-to/restrict-user-input

    Can you please show me how to "Restrict User Input" for the AutoComplete that is inside a Kendo UI (MVC) Grid batch edit mode? The autocomplete is implemented setting an EditorTemplateName bound to a column.

    Thanks,

    Michael

  2. Dimiter Topalov
    Admin
    Dimiter Topalov avatar
    347 posts

    Posted 15 Jun Link to this post

    Hi Oren,

    You can use the approach from the mentioned example, but you have to configure a change event handler in the Editor template, while it will be best to declare the function handler in the script tag of the main/Grid View, e.g.:

    // Editor template:
    ...
    @(Html.Kendo().AutoComplete()
    ...
    e.Change("onChange");
    ...
            })
     
    // Grid View
    ...
    <script>
      function onChange (e){
          var found = false;
    var value = this.value();
    var data = this.dataSource.view();
     
    for(var idx = 0, length = data.length; idx < length; idx++) {
    if (data[idx] === value) {
    found = true;
    break;
    }
    }
     
    if (!found) {
    this.value("");
    alert("Custom values are not allowed");
    }
      }
    </script>

    I hope this helps.

    Regards,
    Dimiter Topalov
    Telerik
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
  3. Kendo UI is VS 2017 Ready
Back to Top