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

Problems with filter

2 Answers 174 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Burke
Top achievements
Rank 1
Burke asked on 10 Sep 2011, 06:12 PM
I can't seem to get the aut0complete to work and recieve the filter.  This may be because a) I don't understand OData, and b) I'm not sure I know what I'm doing with the autocomplete plugin.

I just want to send a filter term to my mvc 3 controller.  That's it.  I don't need a "starts with" or anything like that.  I can't get the mvc parameter binding to pick up on the filter term for some reason.

If I set it to odata, it's looking for $filter.  If I remove the odata specification, it looks like its the 2 dimensional array filter[0]['value']

Is there a way to set the data type to be just a normal query string?

Sorry if I've missed something obvious here.

2 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 12 Sep 2011, 02:12 PM
Hello Burke,

 
In this case you do need the OData transport, because the ASP.NET MVC does not use OData protocol. You just need to add parameters to the query string of the URL. Here is an example:

$("#titles").kendoAutoComplete({
                        minLength: 3,
                        dataTextField: "Name",
                        dataValueField: "Id",
                        dataSource: {
                            transport: {
                                read: "http://Test/Home/Index",
                                dialect: function(data) {
                                    return { text: "2"};
                                }
                            }
                        }
                    });

This will produce this URL:
http://Test/Home/Index?text=2

And the Action method should look like this:
public ActionResult Index(string text)
{
...
}

Regards,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Burke
Top achievements
Rank 1
answered on 12 Sep 2011, 03:45 PM
This is perfect.  The only change I made was to get the value of the input off the data object like so..

dialect: function (data) {
     return { filter: data.filter[0].value };
}
Tags
AutoComplete
Asked by
Burke
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Burke
Top achievements
Rank 1
Share this question
or