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

AutoComplete datasource request is not sending "text"

2 Answers 119 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 26 Jul 2019, 06:30 PM

I'm trying to implement the example I'm seeing here: https://demos.telerik.com/aspnet-core/autocomplete/serverfiltering.  My code is identical to what is provided in the example.

When using the demo on this page, I see the URLs like this (I'm pulling these from developer tools in the browser):

https://demos.telerik.com/aspnet-core/Home/GetProducts?text=test&filter%5Bfilters%5D%5B0%5D%5Bvalue%5D=test&filter%5Bfilters%5D%5B0%5D%5Boperator%5D=contains&filter%5Bfilters%5D%5B0%5D%5Bfield%5D=ProductName&filter%5Bfilters%5D%5B0%5D%5BignoreCase%5D=true&filter%5Blogic%5D=and

The key I want to point out here is that "text=test" is passed on the querystring to my backend page.

However, when I do this in my development environment, no "text" key is passed, I do however have all the filter keys being passed.

Am I doing something wrong?  My code is literally the same as in the example.

Thanks!

2 Answers, 1 is accepted

Sort by
0
Accepted
Ianko
Telerik team
answered on 31 Jul 2019, 09:53 AM
Hi Michael,

The text argument is passed because the Data method is used for the read operation that calls the onAdditinalData function that returns the text argument for the server end-point: 

@(Html.Kendo().AutoComplete()
          .Name("products")
          .DataTextField("ProductName")
          .Filter("contains")
          .MinLength(3)
          .HtmlAttributes(new { style = "width:100%" })
          .DataSource(source => {
              source
                  .Read(read =>
                  {
                      read.Action("GetProducts", "Home")
                      .Data("onAdditionalData");
                  })
                  .ServerFiltering(true);
          })
    )
    <div class="demo-hint">Hint: type "che"</div>
    <script>
    function onAdditionalData() {
        return {
            text: $("#products").val()
        };
    }
    </script>

If you are missing the Data method configured in read operation and/or the JS function that returns the argument, it is expected in the request the text field to not be present. 

If it seems that you have all those pieces, please either share some code of the case, or provide a simple project so that I can see what is going on. 


Regards,
Ianko
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Michael
Top achievements
Rank 1
answered on 31 Jul 2019, 01:42 PM
Thanks for the help, that was my problem.  I had to ensure the Id's matched between the control and the javascript, once I did that, all was well.
Tags
AutoComplete
Asked by
Michael
Top achievements
Rank 1
Answers by
Ianko
Telerik team
Michael
Top achievements
Rank 1
Share this question
or