CheckboxGroup.CheckedItems returns a list of all checked items for all Checkbox Group controls on the page

  1. #1

    CheckboxGroup.CheckedItems returns a list of all checked items for all Checkbox Group controls on the page

    Package versions:
    • Ext.NET: 1.7.0
    • Ext.NET.Utilities: 2.5.0


    I've come across an odd error that appears to be related to the latest version of the Ext.NET.Utilities Nuget package. We recently upgraded this package from v2.2.1 to v2.5. After doing this, we found that, if a page contains multiple CheckboxGroup controls, accessing the CheckedItems property of a particular control returns a list of all checked items for all CheckboxGroup controls on the page, not just the CheckboxGroup control currently being accessed. The following sample demonstrates this:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="CheckboxGroups.Web.Default" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" EnableViewState="false" AjaxViewStateMode="Disabled" RethrowAjaxExceptions="true" />
            <ext:Viewport ID="ViewportMain" runat="server" Layout="FitLayout">
                <Items>
                    <ext:FormPanel ID="FormPanelMain" runat="server" Frame="true" ButtonAlign="Center" AutoScroll="true">
                        <Items>
                            <ext:FieldSet runat="server" Title="Valid Arrival Days" Width="360" HideLabels="True">
                                <Items>
                                    <ext:CheckboxGroup ID="CheckboxGroupArrivalDays" runat="server" ColumnsWidths="48,48,48,48,48,48,48">
                                        <Items>
                                            <ext:Checkbox runat="server" Flag="1" BoxLabel="Mon" Checked="true" />
                                            <ext:Checkbox runat="server" Flag="2" BoxLabel="Tue" Checked="true" />
                                            <ext:Checkbox runat="server" Flag="4" BoxLabel="Wed" Checked="true" />
                                            <ext:Checkbox runat="server" Flag="8" BoxLabel="Thu" Checked="true" />
                                            <ext:Checkbox runat="server" Flag="16" BoxLabel="Fri" Checked="true" />
                                            <ext:Checkbox runat="server" Flag="32" BoxLabel="Sat" Checked="true" />
                                            <ext:Checkbox runat="server" Flag="64" BoxLabel="Sun" Checked="true" />
                                        </Items>
                                    </ext:CheckboxGroup>
                                </Items>
                            </ext:FieldSet>
                            <ext:FieldSet runat="server" Title="Not Valid for stays including" Width="360" HideLabels="True">
                                <Items>
                                    <ext:CheckboxGroup ID="CheckboxGroupInvalidDays" runat="server" ColumnsWidths="48,48,48,48,48,48,48">
                                        <Items>
                                            <ext:Checkbox runat="server" Flag="1" BoxLabel="Mon" />
                                            <ext:Checkbox runat="server" Flag="2" BoxLabel="Tue" />
                                            <ext:Checkbox runat="server" Flag="4" BoxLabel="Wed" />
                                            <ext:Checkbox runat="server" Flag="8" BoxLabel="Thu" />
                                            <ext:Checkbox runat="server" Flag="16" BoxLabel="Fri" />
                                            <ext:Checkbox runat="server" Flag="32" BoxLabel="Sat" />
                                            <ext:Checkbox runat="server" Flag="64" BoxLabel="Sun" />
                                        </Items>
                                    </ext:CheckboxGroup>
                                </Items>
                            </ext:FieldSet>
                        </Items>
                        <Buttons>
                            <ext:Button ID="ButtonSave" runat="server" Icon="Disk" Text="Save">
                                <DirectEvents>
                                    <Click OnEvent="SaveClick">
                                        <EventMask ShowMask="true" />
                                    </Click>
                                </DirectEvents>
                            </ext:Button>
                        </Buttons>
                    </ext:FormPanel>
                </Items>
            </ext:Viewport>
        </form>
    </body>
    </html>
    
    using System.Collections.Generic;
    using System.Linq;
    
    using Ext.Net;
    
    namespace CheckboxGroups.Web
    {
        public partial class Default : System.Web.UI.Page
        {
            protected void SaveClick(object sender, DirectEventArgs e)
            {
                X.MessageBox.Show(new MessageBoxConfig
                {
                    Message = $"Arrival Days: {ToCsv(CheckboxGroupArrivalDays.CheckedItems)}<br/>Invalid Days: {ToCsv(CheckboxGroupInvalidDays.CheckedItems)}",
                    Title = "Selected Items",
                    Buttons = MessageBox.Button.OK
                });
            }
    
            private static string ToCsv(IEnumerable<Checkbox> checkboxes)
            {
                return string.Join(",", checkboxes.Select(x => x.BoxLabel));
            }
        }
    }
    Last edited by plok77; Aug 31, 2023 at 4:15 PM.
  2. #2
    Hello @plok77!

    Unfortunately we couldn't maintain backwards compatibility between latest releases of the Ext.NET.Utilities package with Ext.NET versions as early as 1.7.0. Ext.NET 1.7.0 is referenced to Ext.NET.Utilities 2.2.1. If you really need to keep Ext.NET 1.x yet upgrade Ext.NET.Utilities for any reason, perhaps any of the in-between 2.2.1 and 2.5.0 versions works for you?

    Sorry for the inconvenience. We could get to the bottom to this issue, but there's no telling what else could need further review from that point on, so perhaps best would be to keep the versions in sync.

    Knowing all the challenges involved, upgrading to the latest version of Ext.NET should be the way to go. After all, we're talking about a release made ten years ago.

    Hope you understand.
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Fabricio

    Thanks for your response. I wasn't aware that Ext.NET.Utilities 2.5.0 wasn't compatible with Ext.NET 1.7.0. The package dependences for Ext.NET 1.7.0 state that any version greater than or equal to Ext.NET.Utilities 2.2.1 can be used, so it seemed safe to upgrade. Downgrading the package back to version 2.2.1 fixed the problem.

    We have been developing new features for our application with Ext.NET 7.x. However, we have a lot of legacy code developed with Ext.NET 1.7 which still needs to be maintained and is unlikely to be upgraded in the near future, given the time and resources we have available to us.

    Regards

    Paul
  4. #4
    Hello again, Paul!

    Quote Originally Posted by plok77
    The package dependences for Ext.NET 1.7.0 state that any version greater than or equal to Ext.NET.Utilities 2.2.1 can be used, so it seemed safe to upgrade.
    You are right. We simply didn't want to block people from trying newer versions -- and making their own ones -- in the future. We simply couldn't tell how long new releases would be compatible, and making new releases just to lift a version ban would not be very practical. Unfortunately, after so long, the released version was not really compatible with it.

    I believe by default NuGet would install the exact version it says instead of the latest one, or did you get 2.5.0 by default? That'd be a problem if it's the case. The idea was simply not to block but not really enforce an incompatible latest version.

    Thanks for the feedback!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [CLOSED] checkbox returns uncheck although checked in form
    By jstifel in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 30, 2015, 4:36 PM
  2. Replies: 3
    Last Post: Feb 06, 2015, 12:41 PM
  3. [CLOSED] CheckBoxGroup Items Checked from DirectEvent
    By osef in forum 2.x Legacy Premium Help
    Replies: 6
    Last Post: Apr 01, 2014, 7:26 PM
  4. [CLOSED] Get Checked items of checkbox group
    By mohan.bizbites in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 21, 2013, 5:02 PM
  5. [CLOSED] CheckboxGroup Returns No CheckedItems
    By elisa in forum 2.x Legacy Premium Help
    Replies: 8
    Last Post: Sep 25, 2013, 3:17 PM

Posting Permissions