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

Server Filtering generates ajax requests continuously if the initial request doesn't return anything

1 Answer 98 Views
MultiSelect
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 18 Nov 2013, 11:52 PM
I have a MultiSelect control set up like this:
01.@(Html.Kendo().MultiSelect()
02.     .Name("myCombo")
03.     .DataTextField("Text")
04.     .DataValueField("Value")
05.     .AutoBind(false)
06.     .DataSource(source =>
07.     {
08.          source.Read(read =>
09.          {
10.               read.Action("_SearchAction", "Controller");
11.          })
12.          .ServerFiltering(true);
13.     })
14.)
And I noticed that if I type in a value that doesn't match any records in the database, it keeps on sending ajax requests. Typing something that matches my criteria stops any further requests. Is there a reason why it would behave like that?

1 Answer, 1 is accepted

Sort by
0
Accepted
Ryan
Top achievements
Rank 1
answered on 19 Nov 2013, 04:04 PM
After spending some time investigating, it turned out to be a separate line of code that's causing it to behave like that. There was some JavaScript code outside the wrapper declaration that binds the multiselect's dataBound event to a function which then calls its open method.
1.$("#myCombo").bind("dataBound", function (e)
2.{
3.     this.open();
4.});
This in turn causes it to "loop" into trying to bind over and over again when it doesn't find a value. The open method is called just to automatically open up the multiselect for the user. It can be resolved by either removing the code entirely or adding or adding a check if there was data returned before trying to open it.
Tags
MultiSelect
Asked by
Ryan
Top achievements
Rank 1
Answers by
Ryan
Top achievements
Rank 1
Share this question
or