Toolbar togglable groups: How do I reset these back to the original state?

4 Answers 177 Views
Toolbar
John
Top achievements
Rank 2
Iron
John asked on 10 Nov 2022, 02:41 AM

Hi, 

I've got a very simple Toolbar. It has one buttonGroup with three buttons that all belong to the same group. When the Toolbar initially loads, none of the buttons in the group are selected (toggled on). The user clicks one and all is good.

But, then I have another process on my page that requires me to reset the buttonGroup back to it's original state.  That is, none of the buttons in the Group are selected (toggled on).

Is this possible? 

The only solution I have seen codes like this, but this only removes the class. The "state" of the buttons is unchanged.
$('#ActionsButtons>a.k-selected').removeClass('k-selected');

Thanks for any help,
John

 

4 Answers, 1 is accepted

Sort by
0
Lyuboslav
Telerik team
answered on 14 Nov 2022, 02:27 PM

Hi John,

Thanks for the providing snippet.

In order to, return the ButtonGroup item to the original state(deselect all buttons). You should get the reference to the Toolbar and get the all items in the ButtonGroup component. However, for each item in ButtonGroup, you need to use the "toggle" method and set it to false. Also, to be cleaner I add an id in the Toolbar configuration.

 

{ text: "foo", togglable: true,id:"foo" },
...
var toolbar = $('#toolbar').data('kendoToolBar');
        var toolbarItems = toolbar.options.items[0]['buttons'];
        toolbarItems.forEach(x=>{
          toolbar.toggle(`#${x.id}`,false)
        })
      }); 

Finally, to demonstrate to you, how it works I prepared a sample dojo example. In the example there is n extra button outside of Toolbar. When you click the external button, you could see theat all buttons will be set to the original state.

I hope this will help you.

Regards,
Lyuboslav
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
John
Top achievements
Rank 2
Iron
answered on 14 Nov 2022, 07:54 PM

Hi,

That doesn't quite work. Your dojo example is fine, until you add group: "ActionGroup"  to each of the buttons.  Then the script to set toggle to false doesn't reset the buttons..

So, it's close...but not quite right.

Cheers
John

0
Lyuboslav
Telerik team
answered on 15 Nov 2022, 11:26 AM

Hi John,

Currently we have logged bug with such a scenario. Here I could suggest seeing the bug in our official kendo-UI-core repository.

Based on your report I increased the prioroty of the item.

Let me know if you have additional questions.

Regards,
Lyuboslav
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
John
Top achievements
Rank 2
Iron
answered on 15 Nov 2022, 07:00 PM

Hi,

Thank you. I'll keep an eye on the progress.

Cheers
John

Tags
Toolbar
Asked by
John
Top achievements
Rank 2
Iron
Answers by
Lyuboslav
Telerik team
John
Top achievements
Rank 2
Iron
Share this question
or