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

Is is possible to disable message in single tagMode or display a fixed message

7 Answers 200 Views
DropDownTree
This is a migrated thread and some comments may be shown as answers.
Hüseyin
Top achievements
Rank 1
Hüseyin asked on 12 Sep 2018, 09:07 AM
For following configuration, when all childs of a node are selected, parent nodes are also counted. It causes misunderstanding. If it is not possible to count only leaves, how can a fixed message be displayed.

                checkboxes: { checkChildren: true },
                messages: {
                    singleTag: " selected"
                },
                tagMode: "single",

7 Answers, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 14 Sep 2018, 08:35 AM
Hi Hüseyin,

The DropDownTree does not provide a possibility to configure a tagTemplate similar to the MultiSelect

When the DropDownTree has tagMode 'single', the message can be configured through the messages.singleTag configuration. However, as you pointed out, the count of the selected node is added to the message and the parents nodes are also counted. To avoid displaying the count of the nodes, I would suggest you to subscribe to the close event of the DropDownTree and hide the element that contains the nodes count. 
close: function(e) {
$('.k-dropdowntree .k-multiselect-wrap li.k-button>span:first-child').hide()
},
Here is a Dojo example where a custom message is displayed, without showing the total checked nodes count.

In case you think, that a tagTemplate would be a valuable addition to the DropDownTree I would suggest you to log the idea in our Feedback Portal. Based on the popularity it gain from the community it could be considered for future implementation. 

Regards,
Neli
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.
0
Hüseyin
Top achievements
Rank 1
answered on 17 Sep 2018, 07:09 AM
Thank you Neli.It worked.
0
Andrea
Top achievements
Rank 2
Iron
answered on 09 Mar 2019, 09:37 AM
Still no way to exclude the parent nodes from the items count?
0
Ivan Danchev
Telerik team
answered on 12 Mar 2019, 04:07 PM
Hello,

While excluding parent nodes from the items count is not yet implemented, it is possible to achieve such custom behavior through using the widget's API and jQuery. Here's a dojo example, which demonstrates how you can manually calculate the number of checked/unchecked leaf nodes, exclude parent nodes, and then set the message to the respective span element with jQuery.

Regards,
Ivan Danchev
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.
0
Andrea
Top achievements
Rank 2
Iron
answered on 12 Mar 2019, 05:07 PM

Almost… please check this scenario: https://dojo.telerik.com/AcUJuXuM/2

With:  checkChildren: true, autoClose: false, and the hide also on the change event.

Clicking on child nodes the count works, clicking on parent nodes the count fails.

0
Ivan Danchev
Telerik team
answered on 14 Mar 2019, 01:21 PM
Hello,

When checkChildren is set to true checking/unchecking a parent node respectively checks/unchecks the child nodes. In that scenario the check event does not fire for the child nodes. This requires a change to the logic that calculates the number of checked child items in the check event:
check: function(e) {
  var dataItem = e.sender.dataItem(e.node);
  if(dataItem.hasChildren) {
    dataItem.checked ? count += dataItem.items.length : count -= dataItem.items.length;
  }
  else {
    dataItem.checked ? count++ : count--;
  }
  var string = "item(" + count + ") selected!";
     
  $('.k-dropdowntree .k-multiselect-wrap li.k-button>span:eq(1)').text(string);
}

Updated dojo example.

Regards,
Ivan Danchev
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.
0
Andrea
Top achievements
Rank 2
Iron
answered on 02 Apr 2019, 04:45 PM
Now is perfect! Thanks
Tags
DropDownTree
Asked by
Hüseyin
Top achievements
Rank 1
Answers by
Neli
Telerik team
Hüseyin
Top achievements
Rank 1
Andrea
Top achievements
Rank 2
Iron
Ivan Danchev
Telerik team
Share this question
or