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

Restrict User Input when using AutoComplete inside the Grid

1 Answer 175 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Oren
Top achievements
Rank 1
Oren asked on 11 Jun 2016, 01:07 AM

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

1 Answer, 1 is accepted

Sort by
0
Dimiter Topalov
Telerik team
answered on 15 Jun 2016, 06:14 AM
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.
Tags
AutoComplete
Asked by
Oren
Top achievements
Rank 1
Answers by
Dimiter Topalov
Telerik team
Share this question
or