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

Initialized datasource on page load

3 Answers 438 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Marc
Top achievements
Rank 1
Marc asked on 10 Jun 2016, 04:38 PM

Sorry if this is a repeat. What is the best way to set the autocomplete datasource after the page loads in a document.ready function (not waiting for the user to click on the input)?

I'm using mvc/razor.

 

Thanks

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 14 Jun 2016, 10:31 AM
Hi,

You can use the setDataSource method to set the autocomplete dataSource via JavaScript.

Regards,
Daniel
Telerik
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
0
Marc
Top achievements
Rank 1
answered on 15 Jun 2016, 09:23 PM

Thanks one more question. If I have a custom datasource, how can I send in an additional parameter via javascript?

I'm looking for a combination of:

@(Html.Kendo().AutoComplete()
      .Name("Field")
      .DataTextField("Field")
      .Filter("startswith")
      .MinLength(4)

      .DataSource(source =>
      {
          source.Custom()
              .ServerFiltering(true)
              .Type("aspnetmvc-ajax")
              .Transport(t =>
              {
                  t.Read("GetThings", "Controller");
              })
              .Schema(schema =>
              {
                  schema.Data("Data").Total("Total");
              });
      })

)

 

and

 

 .DataSource(d =>
 {
     d.ServerFiltering(false);
     d.Read(r => r.Action("GetThings", "Controller").Data("getData()"));
 })

 

0
Daniel
Telerik team
answered on 17 Jun 2016, 08:33 AM
Hello again,

You can use the same approach with the custom dataSource:
.Transport(t =>
{
  t.Read(read => read.Action("GetThings", "Controller").Data("getData()"));
})


Regards,
Daniel
Telerik
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
Tags
AutoComplete
Asked by
Marc
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Marc
Top achievements
Rank 1
Share this question
or