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

Remove "Select All" options from multiselect check box in Kendo Grid view

1 Answer 2600 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Deepa
Top achievements
Rank 1
Deepa asked on 13 Sep 2019, 06:39 PM

I want to remove the "Select All" option from multi select check box filter in kendo grid view, when there is no data to be shown on UI or when grid is empty.

Any setting i can do to do so?

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 18 Sep 2019, 03:20 PM
Hi Ankit,

To achieve removing the "Select All" option from the checkbox filter menu, you could use the filterMenuInit event. In the event handler function, select the closest "li" element of the "Check All" checkbox and the "div" of the "selected items" and use the jQuery hide method. Then you could add a condition, checking if the Grid datasource is empty and hide the element:

filterMenuInit: function(e) {
  var filterMultiCheck = this.thead.find("[data-field=" + e.field + "]").data("kendoFilterMultiCheck")
  var container = e.container;
  var checkAll = container.find(".k-check-all").closest("li");
  var selectedItems = container.find(".k-filter-selected-items");
  if ($("#client").data("kendoGrid").dataSource.data().length < 1 ) {
    checkAll.hide();
    selectedItems.hide();
  }
},

In case your Grid receives data you would need to show the "Select All". To do so you could use filterMenuOpen event handler:

filterMenuOpen: function(e) {
  var filterMultiCheck = this.thead.find("[data-field=" + e.field + "]").data("kendoFilterMultiCheck")
  var container = e.container;
  var checkAll = container.find(".k-check-all").closest("li");
  var selectedItems = container.find(".k-filter-selected-items");
  if ($("#client").data("kendoGrid").dataSource.data().length > 0 ) {
    checkAll.show();
    selectedItems.show();
  }
},

The above approach you can see live at the below Dojo example, I have prepared:

Hope this helps and please contact us back in case of further questions.

Regards,
Nikolay
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Deepa
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or