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

[Solved] AutoComplete javascript error: Object #<Object> has no method 'replace'

4 Answers 79 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Lucian Duma
Top achievements
Rank 1
Lucian Duma asked on 27 Jun 2011, 02:40 PM
Hello,


I'm trying to use the AutoComplete control. For databinding I'm using Ajax:

@(Html.Telerik().AutoComplete()
                .Name("searchCollaborators")
                .DataBinding(binding => binding.Ajax().Select("SearchByName", "id"))
                .HighlightFirstMatch(true)
                .AutoFill(true)
)


In my controller I've set the following action:

public ActionResult SearchByName(string text) {
List<Employee> employees = Facade.Employee.GetEmployeeByName(text);
List<EmployeeDescription> result = new List<EmployeeDescription>();
foreach (Employee employee in employees) {
result.Add(new EmployeeDescription() { Id = employee.Id, Name = employee.Name });
}

return new JsonResult { Data = result };
}


the class EmployeeDescription is just a dummy DTO that contains the Name and Id properties):


public class EmployeeDescription {
public string Name { get; set; }
public int Id { get; set; }
}


I've also set the following rule in the Global.asax.cs:

routes.MapRoute(
    "SearchEmployeesByName", // Route name
    "id/SearchByName/{nameFilter}", // URL with parameters
    new { controller = "Identity", action = "SearchByName", nameFilter = UrlParameter.Optional } // Parameter defaults
);


When I try to use the autocomplete by entering some text, the ajax call is ok. The breakpoint enters my action, filters the data and sends back a valid JsonResult.
The returned type is application/json, POST is 200, so I guess everything is ok. However, the autocomplete is not shown, and the following errror occurs in the jquery source code:


Uncaught TypeError: Object #<Object> has no method 'replace'


I've created my project using the Telerik template, and I'm only using the jquery from the telerik asset.axd handler.
The scriptregistrar is also in place (was added by the Telerik Visual Studio 2010 template when I created the project), everything seems to be on place and I can't figure out what is wrong.
[UPDATE]: I'm using Telerik.Web.Mvc.dll, version 2011.1.315.340

Any ideas?


Thanks.
Lucian

4 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 27 Jun 2011, 03:53 PM
Hello Lucian,

 
It is hard to determine where could be the issue, depending on the given information. Could you please try the latest official release of Telerik extensions for ASP.NET MVC?

If the problem still persists I will ask you to send us a simple test project which reproduces the depicted issue.

Kind regards,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Lucian Duma
Top achievements
Rank 1
answered on 28 Jun 2011, 09:39 AM
Hello Georgi, thanks for the reply.

I would love to try the newest version but in fact it looks that we are all stucked with 2011.1.315. About that, here is something weird: at this link, the newest version should be 2011.1.414. But when I click the download button, I'm redirected back to 2011.1.315.

The same happens with the Upgrade dialog from Visual Studio, I'm told that there is a newer version, but when I enter my credentials I am unable to download it.

I've fount this post that explains what's going on so  guess I need to wait until Q22011 comes out?

Thanks.

Lucian

PS: Meanwhile I'll try to reproduce the issue on a new project.
0
Georgi Krustev
Telerik team
answered on 28 Jun 2011, 10:07 AM
Hello Lucian,

 
Yes, the second link which you found explains the situation correctly. In this case, you will need to wait for the Q2 2011 release to try the fixes.

Regards,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Lucian Duma
Top achievements
Rank 1
answered on 05 Jul 2011, 12:13 PM
I've solved my problem.

It was dued to the type of the returned data.
My DTO was ok, but the autocomplete had no ideea about it's properties and how it should use it to populate the autocomplete box.
Taking as an example the demo page, it worked by not returning a List<EmployeeDescription> but returning a List<string>.

Since I needed the ID of the employee, not only his name, I'm using now the ComboBox and works really good.

Thanks for your assistence.

Lucian
Tags
General Discussions
Asked by
Lucian Duma
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Lucian Duma
Top achievements
Rank 1
Share this question
or