Initialized datasource on page load

4 posts, 0 answers
  1. Marc
    Marc avatar
    73 posts
    Member since:
    Jul 2010

    Posted 10 Jun 2016 Link to this post

    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

  2. Daniel
    Admin
    Daniel avatar
    2145 posts

    Posted 14 Jun 2016 Link to this post

    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.
     
  3. Marc
    Marc avatar
    73 posts
    Member since:
    Jul 2010

    Posted 15 Jun 2016 in reply to Daniel Link to this post

    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()"));
     })

     

  4. Daniel
    Admin
    Daniel avatar
    2145 posts

    Posted 17 Jun 2016 Link to this post

    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.
     
Back to Top