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

Filter menu dropdown does not refresh grid when no option label used

6 Answers 213 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 24 Mar 2014, 06:11 PM
When a column filter is set to a dropdownlist but no option label is set hitting filter does not filter the grid until the dropdownlist value is changed.  http://trykendoui.telerik.com/ojUV

6 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 25 Mar 2014, 03:22 PM
Hi Ryan,


With the current implementation, you should bind to the filterMenuInit event of the Grid and trigger the change event of the custom DropDownList.
E.g.
filterMenuInit: function(e){
  if(e.field === "City"){
    e.container.find("input").data("kendoDropDownList").trigger("change");
  }
}

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Ryan
Top achievements
Rank 1
answered on 25 Mar 2014, 03:46 PM
I don't think that would work. I wouldn't want to filter on filterMenuInit, I would want to filter only if the user clicks the Filter button.

1. Custom filter menu is applied
2. Grid is created
3. User opens custom filter menu which shows "City" instead of "Select one" in order to allow filtering of first valid value without requiring clicks.
4. Only if user clicks Filter do I apply the filter using the city, e.g. Seattle.

Does that make sense?
0
Dimiter Madjarov
Telerik team
answered on 25 Mar 2014, 04:09 PM
Hello,

Have you tried the suggested approach on your side, as I think that it covers the current requirements? Here is the updated example.

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Ryan
Top achievements
Rank 1
answered on 25 Mar 2014, 05:05 PM
It works for the first filter click. After clicking clear and then filter it fails once again.
0
Accepted
Dimiter Madjarov
Telerik team
answered on 26 Mar 2014, 11:48 AM
Hi Ryan,


Indeed your observation is correct. The workaround for this issue consist of two parts - first we should bind to the open event of the filter menu popup, so that the custom logic is executed each time the menu is opened, not just the first one. Then we should explicitly set the value of the dropdownlist element, which was cleared.
E.g.
filterMenuInit: function(e){
  if(e.field === "City"){
    e.container.data("kendoPopup").bind("open", function() {
      var ddl = e.container.find("input").data("kendoDropDownList");
      ddl.element.val(ddl.dataItem());
      ddl.trigger("change");
    });
  }
}

Here is the updated version of the example.

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Ryan
Top achievements
Rank 1
answered on 26 Mar 2014, 02:27 PM
Hi Dimiter,

Interesting use of the undocumented kendoPopup base widget. The workaround works as expected. Thank you
Tags
Grid
Asked by
Ryan
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Ryan
Top achievements
Rank 1
Share this question
or