RadSplitButtonElement : dropdown opened on button click

8 posts, 0 answers
  1. jacques
    jacques avatar
    4 posts
    Member since:
    Oct 2013

    Posted 14 Apr 2017 Link to this post

    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

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3194 posts

    Posted 17 Apr 2017 Link to this post

    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.
  3. jacques
    jacques avatar
    4 posts
    Member since:
    Oct 2013

    Posted 19 Apr 2017 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    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.

  4. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3194 posts

    Posted 20 Apr 2017 Link to this post

    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.
  5. jacques
    jacques avatar
    4 posts
    Member since:
    Oct 2013

    Posted 24 Apr 2017 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    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.

  6. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3194 posts

    Posted 24 Apr 2017 Link to this post

    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.
  7. Ioannis
    Ioannis avatar
    35 posts
    Member since:
    Dec 2018

    Posted 04 Jan Link to this post

    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

  8. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3194 posts

    Posted 09 Jan Link to this post

    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.
Back to Top