ButtonGroup, How do you get the pressed button in a function (MVC kendo UI)

1 Answer 36 Views
ButtonGroup
cameron
Top achievements
Rank 1
Iron
cameron asked on 26 Jan 2022, 09:14 PM

How do you get the pressed button in a button group from a function .

 

Thanks in advance,


1 Answer, 1 is accepted

Sort by
0
Petar
Telerik team
answered on 28 Jan 2022, 07:17 AM

Hi Cameron,

To achieve the targeted functionality, you can use the select event of the ButtonGroup and execute a logic similar to the below one, once the event is triggered:

    function onSelect(e) {
        var index = this.current().index();
        var text = this.current()[0].innerText;
       /* The result can be observed in the DevTools(F12) console of the browser. */
        console.log(index);
        console.log(text);
    }

The code in yellow will return the index of the pressed button inside the ButtonGroup and the code in green will return its text. 

Here is a REPL example demonstrating the above implementation in UI for ASP.NET Core context. The same as the demonstrated implementation is valid in the UI for ASP.NET MVC. 

I hope the above will help you achieve what you need in your project.

Regards,
Petar
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
ButtonGroup
Asked by
cameron
Top achievements
Rank 1
Iron
Answers by
Petar
Telerik team
Share this question
or