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

RadSplitButtonElement : dropdown opened on button click

7 Answers 408 Views
Menu
This is a migrated thread and some comments may be shown as answers.
jacques
Top achievements
Rank 1
jacques asked on 14 Apr 2017, 09:13 AM

Hi,

When I click the button element of the RadSplitButtonElement, the dropdown do open and fire click.

Like in MS-Office, I expect the button to fire click, but not open the dropdown. The dropdown should only be opened when clicking the arrow part.

Note : I'm using version 2016.3.1024.40

How can I change this behavior ?

Thanks

7 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 17 Apr 2017, 07:32 AM
Hello Jacques, 

Thank you for writing.  

This is desired behavior to open the drop down when clicking the split button, not only the arrow. However, you can cancel the DropDownOpening when the user doesn't click the arrow. Here is a sample code snippet:
public RadForm1()
{
    InitializeComponent();
      
    this.radSplitButton1.DropDownButtonElement.ArrowButton.MouseDown += ArrowButton_MouseDown;
    this.radSplitButton1.DropDownOpening += radSplitButton1_DropDownOpening;
}
 
private void ArrowButton_MouseDown(object sender, MouseEventArgs e)
{
    this.radSplitButton1.Tag = "cancel";
}
 
private void radSplitButton1_DropDownOpening(object sender, EventArgs e)
{
    RadPopupOpeningEventArgs args = e as RadPopupOpeningEventArgs;
    if (this.radSplitButton1.Tag == null && args!=null)
    {
        args.Cancel = true;
    }
    this.radSplitButton1.Tag = null;
}

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
jacques
Top achievements
Rank 1
answered on 19 Apr 2017, 02:32 PM

Quite hacky, but it's working quite fine.

I had to wire ActionButton.MouseDown too, because a click on the arrow, then a click on the ActionButton allow the dropdown to open once.

rdbtEffacer.ArrowButton.MouseDown += splitButton_MouseDown;
rdbtEffacer.ActionButton.MouseDown += splitButton_MouseDown;
rdbtEffacer.DropDownOpening += splitButton_DropDownOpening;

 

private void splitButton_MouseDown(object sender, MouseEventArgs e)
{
    if(sender is ActionButtonElement)
        ((RadItem)(((RadElement)sender).Parent).Parent).Tag = "cancel";
    else ((RadItem)(((RadElement)sender).Parent).Parent).Tag = "allow";
}
private void splitButton_DropDownOpening(object sender, CancelEventArgs e)
{
    RadItem s = sender as RadItem;
    if (s != null)
    {
        if (s.Tag == null || s.Tag.ToString() != "allow")
            e.Cancel = true;
        s.Tag = null;
    }
}

 

Is it possible to implement a simple property of the RadSplitButtonElement to have this functionality out of the box ? As it, there is just no fundamental difference between raddropdownbuttonelement and radsplitbuttonelement behavior, and it's not consistent with MS-Office guidelines.

Thanks.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 20 Apr 2017, 09:01 AM
Hello Jacques, 

Thank you for writing back. 

Your feedback is greatly appreciated. If we have similar requests from other customers we will consider it in the future control's improvement. Note that RadDropDownButton is visually indistinguishable from RadSplitButton, but there is an important programmatic distinction. On RadSplitButton the DefaultItem property indicates the item whose Click event should be triggered when the button is clicked. If you want a button that does something when clicked as well as when a selection is made from the menu, you should use a RadSplitButton instead of a RadDropDownButton. Once, the DefaultItem is set, the popup is not supposed to be shown when clicking the action part. You can refer to our Demo application >> Buttons >> SplitButton example.  

I hope this information helps. If you have any additional questions, please let me know. 

Regards,
Dess
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
jacques
Top achievements
Rank 1
answered on 24 Apr 2017, 09:48 AM

Hi Dess,

Thanks for DefaultItem tips ! It's a much better answer than the previous one !

Only drawback is the need to do this by code, as it's not available through designer.

Here is my code to apply this behavior to the whole menu :

radRibbonBar1.CommandTabs.OfType<RibbonTab>().SelectMany(t => t.Items.OfType<RadRibbonBarGroup>().SelectMany(g => g.Items.OfType<RadSplitButtonElement>()))
    .ToList().ForEach(btn =>
    {
        btn.DefaultItem = btn.ActionButton;
    });

 

Thanks.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 24 Apr 2017, 10:44 AM
Hello Jacques, 

Thank you for writing back. 

I am glad that suggested solution was helpful. Indeed, the DefaultItem property can be set programmatically, but not at design timе.

If you have any additional questions, please let me know. 

Regards,
Dess
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Ioannis
Top achievements
Rank 2
answered on 04 Jan 2019, 02:04 PM

I, too, think that the RadSplitButton should have an option to turn its behaviour similar to the MS Office's split button.

In most cases, this RadSplitButton's behaviour can be subsumed under the RadDropDownButton's behaviour.

I'm certainly voting this up, and for the time being, I'll try Dess' solution

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 09 Jan 2019, 07:35 AM
Hello, Ioannis,  

As it was previously explained, opening the drop down when clicking the split button is a desired behavior. Thank you for sharing your feedback. It is valuable for us.

Feel free to use the suggested solution in my previous replies.

Should you have further questions please let me know.

Regards,
Dess | Tech Support Engineer, Sr.
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
Menu
Asked by
jacques
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
jacques
Top achievements
Rank 1
Ioannis
Top achievements
Rank 2
Share this question
or