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

Difficulty naming parameter on remote call

1 Answer 51 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Stacey
Top achievements
Rank 1
Stacey asked on 20 Sep 2013, 08:49 PM
I am attempting to hit an ASP.NET MVC controller action with the Kendo Datasource from the "Autocomplete" widget. The controller looks a bit like this ..


public JsonResult Aspect(string term){
  // ...
}
So I need the actual URL parameter to be called "term" from the dataSource. So given this..

$(".autocomplete").kendoAutoComplete({
    dataTextField: "Name",
    dataSource: {
        type: "json",
        transport: {
            read: "/search/aspect",
            data: { term: $(this).val() }
        }
    }
});
I can't seem to get this to work though.

Also, it is important to note that there are MULTIPLE auto-completes on the page with dynamic identities. So it cannot work to call a specific selector.

I have been looking for a few hours, and I'm not seeming to find a way to do this.

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 23 Sep 2013, 02:04 PM
Hi Stacey,

 This can be done via the parameterMap option of the data source. Here is a live demo showing how:

$(".autocomplete").kendoAutoComplete({
  dataTextField: "Name",
  dataSource: {
    transport: {
      read: {
        url: "search/aspect",
        dataType: "json"
      },
      parameterMap: function(options) {
        return {
          term: options.filter.filters[0].value
        };
      }
    },
    serverFiltering: true
  }  
});

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Data Source
Asked by
Stacey
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or