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

[Solved] Using Autocomplete when editing an MVC grid

1 Answer 199 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
jmo
Top achievements
Rank 1
jmo asked on 28 Feb 2011, 02:38 PM

I am using a Telerik MVC grid, which is bound to a model object.

For one of the Model's properties, I would like to use a Telerik Autocomplete control.

This works fine for inserting a data row, the Insert form is displayed correctly, and when I start typing in the textbox generated by the Autocomplete control, the options I have set appear fine, and I can select one. Clicking save saves the selected string correctly.

The problem I have is on an Edit of an existing data row.

As soon as I click Edit, it crashes out into Telerik.Grid.Editing.min.js on:


this.evaluate=function(r,u){var q=r,s=false,w=u.split(".")

...saying that "u is undefined".

My EditTemplate looks like this:


<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<string>" %>
 
<script type="text/javascript">
 
function onAutoCompleteDataBinding(e) {
    var autocomplete = $('#City').data('tAutoComplete');
    autocomplete.dataBind(["Chicago", "New York"], true);
}
</script>
 
 <%= Html.Telerik().AutoCompleteFor(a => a)
   .Name("City")
   .ClientEvents(events => events
   .OnDataBinding("onAutoCompleteDataBinding")) 
 %>

I've tried registering the javascript files manually as per http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-required-javascript-files.html but it hasn't helped.

I am also aware of the JQuery UI Autocomplete, but I can't get it to work within the Telerik MVC grid, it's on the backburner for now.

I'm using Telerik MVC v.2010.2.930 and JQuery 1.4.2

Can anyone help?


I've asked this on Stackoverflow as well http://stackoverflow.com/questions/5142581/editing-a-value-with-a-telerik-mvc-autocomplete-within-a-telerik-mvc-grid

1 Answer, 1 is accepted

Sort by
0
jmo
Top achievements
Rank 1
answered on 01 Mar 2011, 05:01 PM
I went with JQuery AutoComplete in the end, worked like a charm.
Tags
Grid
Asked by
jmo
Top achievements
Rank 1
Answers by
jmo
Top achievements
Rank 1
Share this question
or