Gaz Winter
Gaz Winter

Reputation: 2989

Kendo Autocomplete not posting to Server

I am a bit stumped as to why my Kendo Autocomplete is not posting to the server.

Can anyone see a problem with this?

@(Html.Kendo().AutoComplete()
    .Name("LinkSearch")
    .Filter("contains")
    .MinLength(3)
    .DataTextField("value")
    .DataSource(source => {
        source.Read(read =>
        {
            read.Action("_LinkSearch", "Record", new { area="record" })
                .Data("onAdditionalData");
        })
        .ServerFiltering(true);
     })
)

<script>
    function onAdditionalData() {
        return {
            searchTerm: $("#LinkSearch").val()
        };
    }
</script>

As far as I am concerned this should work. This is based on the examples on the Kendo page. The rest of the Kendo controls on the page work without any issues.

The box renders perfectly fine, but just doesn't post to the server when the user types in it and therefore never returns any data.

I have a breakpoint on the Action and am monitoring the network traffic, but it never even tries to hit the server.

Cheers Gareth

Upvotes: 2

Views: 266

Answers (1)

Gaz Winter
Gaz Winter

Reputation: 2989

It turns out that the problem was due to the Routing somewhere.

Record is a base controller and by changing the controller in the read.Action to the controller that was inheriting from the base controller it worked fine. As far as I am aware it should have worked either way, but for some reason it doesn't.

It took a couple of us a good couple of hours to get to the bottom of it.

Upvotes: 1

Related Questions