Need More Info
Last Updated: 20 Jan 2025 21:30 by ADMIN
Chris
Created on: 19 Jan 2025 20:25
Category: ButtonGroup
Type: Bug Report
0
Get reference to an existing ButtonGroup widget object causes the selection property to change to "single"

I use the ASP.NET MVC widget code to add a ButtonGroup to a view. The ButtonGroup configuration has 2 buttons, has selection = many, and one of the buttons is selected. 


            @(Html.Kendo().ButtonGroup()
                .Name("select-data-source-filters")
                .HtmlAttributes(new { @class = "", @style = "text-align: center; flex-flow: row;"})
                .Selection("multiple")
                .Items(t =>
                {
                    t.Add().Text("Include Default Product Scenarios").Selected(false).HtmlAttributes(new { @id = "databaseItems", @class= "mb-2 k-ml-2.5" });
                    t.Add().Text("Include User Defined Product Scenarios").Selected(true).HtmlAttributes(new { @id = "userDefinedItems", @class = "mb-2 ml-2" });
                })
            )

 

In an event handler for a different widget (e.g., Grid), I programmatically select the button that is not yet selected. This should cause both buttons to now be selected. However, the act of getting a reference to the button group widget object causes the selection property to be reset to "single". The workaround is to manually reset the selection option to "multiple". 

                        let buttonGroupWidget = $("#select-data-source-filters").kendoButtonGroup().data("kendoButtonGroup");
                        if (debugLevel > 0) {
                            console.log(".... buttonGroupWidget = " + buttonGroupWidget + " : ", buttonGroupWidget);
                            console.log(".... (initial) buttonGroupWidget.selectedIndices = " + buttonGroupWidget.selectedIndices + " : ", buttonGroupWidget.selectedIndices);
                        }
                        if (buttonGroupWidget !== null && buttonGroupWidget !== undefined) {
                            buttonGroupWidget.options.selection = "multiple";//workaround for a bug in 2024Q3 that resets selection to single when get reference to the kendo widget
                            buttonGroupWidget.select(0);
                            buttonGroupWidget.trigger("select");
                            console.log(".... (updated) buttonGroupWidget.selectedIndices = " + buttonGroupWidget.selectedIndices + " : ", buttonGroupWidget.selectedIndices);
                        }

1 comment
ADMIN
Eyup
Posted on: 20 Jan 2025 21:30

Hello Chris,

 

Thank you for writing to us.

This following line duplicates the creation of the buttongroup:

 let buttonGroupWidget = $("#select-data-source-filters").kendoButtonGroup().data("kendoButtonGroup");

Which might lead to all kind of unwanted behavior.

Can you remove the highlight part and let me know if this resolves the issue?

 

Regards,
Eyup
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.