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

Cached Server Filtering

3 Answers 187 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Odd Veibust
Top achievements
Rank 1
Odd Veibust asked on 30 Sep 2014, 03:28 PM
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);
        }

3 Answers, 1 is accepted

Sort by
0
Odd Veibust
Top achievements
Rank 1
answered on 30 Sep 2014, 03:32 PM
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.  
0
Accepted
Georgi Krustev
Telerik team
answered on 02 Oct 2014, 08:36 AM
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.

 
0
Odd Veibust
Top achievements
Rank 1
answered on 02 Oct 2014, 03:14 PM
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.
Tags
DropDownList
Asked by
Odd Veibust
Top achievements
Rank 1
Answers by
Odd Veibust
Top achievements
Rank 1
Georgi Krustev
Telerik team
Share this question
or