RadSplitButtonElement : dropdown opened on button click

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

    Posted 14 Apr 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
    Admin
    Dess avatar
    2107 posts

    Posted 17 Apr 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 in reply to Dess 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
    Admin
    Dess avatar
    2107 posts

    Posted 20 Apr 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 in reply to Dess 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
    Admin
    Dess avatar
    2107 posts

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