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

2 posts, 1 answers
  1. Ryan
    Ryan avatar
    8 posts
    Member since:
    Jan 2012

    Posted 18 Nov 2013 Link to this post

    I have a MultiSelect control set up like this:
    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.     })
    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?
  2. Answer
    Ryan avatar
    8 posts
    Member since:
    Jan 2012

    Posted 19 Nov 2013 Link to this post

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