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

Open Split Button With JS

3 Answers 407 Views
Toolbar
This is a migrated thread and some comments may be shown as answers.
Justavian
Top achievements
Rank 1
Justavian asked on 10 Nov 2014, 04:31 PM
I can't figure out how i might fly out a split button programmatically.  My toolbar has an "export" function that is controlled with a split button.  I want the user to be able to click on any part of the button to expand the options.  However, the out of the box functionality is set up to only show the options when the user clicks directly on the little arrow of the split button.

I've got a way to do it, but it feels a bit messy.  What i'm doing right now is detecting the click on the main body of the split button, and then i have to set a timeout and fire both mouse down and mouse up on the arrow:


var btnClicked = e.target.closest(".k-split-button");
var btnSplitParent = btnClicked.closest(".k-split-button");
if (btnSplitParent.length > 0 && !btnClicked.hasClass("k-split-button-arrow")) {
    setTimeout(function () {
        btnSplitParent.find(".k-split-button-arrow").mousedown();
        btnSplitParent.find(".k-split-button-arrow").mouseup();
    }, 100);
 
}


Is there a better way to accomplish this same thing?
Matthew
Top achievements
Rank 1
Veteran
commented on 06 Nov 2021, 02:57 PM

How does one:

 // find .k-split-button element

When the button is from a click event on a kendoToolBar?

Martin
Telerik team
commented on 09 Nov 2021, 12:52 PM

Here is a small example how to open the popup in the described scenario. Let me know if that works for you.

3 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 12 Nov 2014, 10:11 AM
Hi Justavian,

The SplitButton itself does not have an open method, but the SplitButton's Popup component do have one.
You may use the following approach:

var element; // find .k-split-button element
var popup = element.data("kendoPopup");
 
if (popup) { popup.open() }


Regards,
Alexander Valchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Naveen
Top achievements
Rank 1
answered on 23 Oct 2020, 08:11 AM
Do we have toggle() method there? if not how to check state of the popup?
0
Aleksandar
Telerik team
answered on 26 Oct 2020, 03:18 PM

Hi Naveen,

The toggle event handler of the button for the Toolbar items is applicable only for commands of type button and togglable: true. For commands of type splitButton you can specify a click event handler via the toolbar.items.click configuration option.

Here is an example of how you can get the id of the clicked split button option.

I hope this helps.

Regards,
Aleksandar
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/.

Tags
Toolbar
Asked by
Justavian
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Naveen
Top achievements
Rank 1
Aleksandar
Telerik team
Share this question
or