Cached Server Filtering

4 posts, 1 answers
  1. Odd Veibust
    Odd Veibust avatar
    26 posts
    Member since:
    Feb 2007

    Posted 30 Sep 2014 Link to this post

    Hi.

    I'm having a small issue with a DropDownList using server filtering. I have added a DropDownList with server filtering, and it is working as it should. My issue is that I have some checkboxes that should influence the result of the filtering. The problem is that when I have clicked the DropDownList it caches the result the next time I click it, until I type some text for the text filter.

    Here is how it now works.

    1) As you can see in Fig1 of the attached files, the first time I click it, it returns 1260 results
    2) I then check the CheckBox "Choice1" and then click the DropDownList again, it still shows 1260 results (is supposed to be 383) and the data read method in the controller is not even triggered.

    Is there some way I can get the DropDownList not to cache the results on the click, so that each time it is clicked the data read method is called?

    Here's from the cshtml file:

    @(Html.Kendo().DropDownListFor(m => m.Lines[i].Product.Id)
                                                          .DataTextField("Value")
                                                          .DataValueField("Id")
                                                          .OptionLabel(" ")
                                                          .AutoBind(false)
                                                          .Text(Model.Lines[i].Product.Description)
                                                          .Filter("contains")
                                                          .DataSource(source =>
                                                          {
                                                              source.Read(read =>
                                                              {
                                                                  read.Action("SearchProductLandingNote", "ReportSearchResultSurface");
                                                              })
                                                              .ServerFiltering(true);
                                                          }))

    And here's from the backing controller:

            public JsonResult SearchProductLandingNote(string text)
            {
                SurofiUser sUser = UserUtilities.GetLoggedInUser();

                var products = RegisterUtilities.Instance.Products.Where(ca => ca.Description != null || ca.Code != null).ToList();

                //
                // Some code that filters from the checkboxes, the info from the checkboxes are stored on the User
                // Checked in debugging and works fine when the method is actually called
                //

                return Json(products, JsonRequestBehavior.AllowGet);
            }

  2. Odd Veibust
    Odd Veibust avatar
    26 posts
    Member since:
    Feb 2007

    Posted 30 Sep 2014 Link to this post

    Fig3 is what it should return, and what it returns if I refresh the page, so that the filter method in the controller is called.  
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Answer
    Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 02 Oct 2014 Link to this post

    Hello Odd Veibust,

    I am not exactly sure how the "checkboxes" logic interferes the DropDownList data state (probably the data is filtered on server and widget is not notified), but if you would like to retrieve the data on open then you can wire the open event [ .Events(e => e.Open("open")); ] and call the data source read method to force server request:
    function open() {
      this.dataSource.read();
    }

    Let me know if I am missing something.

    Regards,
    Georgi Krustev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  5. Odd Veibust
    Odd Veibust avatar
    26 posts
    Member since:
    Feb 2007

    Posted 02 Oct 2014 Link to this post

    Thanks for the answer.

    Together with "[OutputCache(Duration = 0, NoStore = true)]" on the server method it worked. Generated some strange animation behaviour, looked like it opened twice. But by switching animation off it works for now.
Back to Top
UI for ASP.NET MVC is VS 2017 Ready