Dynamically add select all and unselect all to group in ext

  1. #1

    Dynamically add select all and unselect all to group in ext

    In the below .aspx markup based on group field the tree view is getting bound in the frontend but to that tree view for the child values I need to bind select all and unselect all based on the condition like if all the child values in the Group are selected the it should show Unselect all, if child values are not selected it should show Select All. How can I achieve this?

    <ext:Store ID="stStudents" runat="server" GroupField="Subjects">
        <Model>
            <ext:Model ID="Model8" runat="server">
                <Fields>
                    <ext:ModelField Name="ID" />
                    <ext:ModelField Name="Name" />
                </Fields>
            </ext:Model>
        </Model>
        <Sorters>
            <ext:DataSorter Property="Name" Direction="ASC" />
        </Sorters>
    </ext:Store>
    <ext:Container runat="server">
        <LayoutConfig>
            <ext:HBoxLayoutConfig Align="Middle"/>
        </LayoutConfig>
        <Items>
            <ext:DisplayField runat="server" FieldLabel="<%$ Resources: Src,Rpeople%>" ID="DisplayField1"></ext:DisplayField>
            <ext:Panel runat="server" Flex="25" Title="<%$ Resources: Src,people%>">
                <Items>
                    <ext:MultiSelect runat="server" ID="MultiSelect1" MultiSelect="true" DisplayField="Name" ValueField="ID" ShowCheckbox="false" SingleSelect="true" StoreID="stpeople">
                    </ext:MultiSelect>
                    <ext:GridPanel ID="GridPanel1" runat="server" Border="true" TitleAlign="Center" AutoHeight="true" Hidden="true" StoreID="stpeople">
                        <ColumnModel ID="ColumnModel2" runat="server">
                            <Columns>
                                <ext:Column ID="Column1" runat="server" Text="<%$ Resources: Src,Name%>" DataIndex="Name" Flex="1">
                                </ext:Column>
                                <ext:CommandColumn runat="server" Hidden="true">
                                    <GroupCommands>
                                        <ext:CommandSpacer/>
                                        <ext:GridCommand Icon="Tick" CommandName="Select All">
                                            <ToolTip Title="Select" Text="" />
                                        </ext:GridCommand>
                                        <ext:CommandSpacer/>
                                        <ext:GridCommand Icon="Cross" CommandName="DeSelect All">
                                            <ToolTip Title="Deselect" Text="" />
                                        </ext:GridCommand>
                                    </GroupCommands>
                                    <Listeners>
                                        <GroupCommand Fn="onGroupCommand" />
                                    </Listeners>
                                </ext:CommandColumn>
                            </Columns>
                        </ColumnModel>
                        <SelectionModel>
                            <ext:CheckboxSelectionModel runat="server" ID="CheckboxSelectionModel1" Mode="Simple" ShowHeaderCheckbox="true">
                            </ext:CheckboxSelectionModel>
                        </SelectionModel>
                        <View>
                            <ext:GridView ID="GridView1" runat="server" TrackOver="false" ></ext:GridView>
                        </View>
                        <Features>
                            <ext:GroupingSummary runat="server" EnableNoGroups="true" HideGroupedHeader="true" EnableGroupingMenu="false" StartCollapsed="true">
                            </ext:GroupingSummary>
                        </Features>
                    </ext:GridPanel>
                </Items>
            </ext:Panel>
        </Items>
    </ext:Container>
    Last edited by fabricio.murta; May 16, 2023 at 1:38 AM. Reason: Wrap [code][/code] blocks around code.
  2. #2
    Hello, @avair, and welcome to Ext.NET forums!

    I believe this thread pretty much covers all issues (including the "please wrap code in [code][/code] blocks" part):

    - Treepanel cascade check

    All that's left is, maybe, implementing the "check all" logic. If you have a big (and deep) tree of elements, you may need to use some optimization (like updating check state as a single node changes instead of parsing the whole tree), but the idea will basically be what's in there.

    Some other points not really related to the question but that might help getting your posts through here:

    - We have noticed you made another post, exactly identical to this one, and deleted it;
    - We edited your message to wrap your code text in a [code][/code] block;
    - The provided code sample was for Ext.NET 5, and the post made in 7.x forums; we moved it to the correct forums;
    - The provided code sample clearly has some references to data coming from data sources probably pertaining your actual project; it is more useful, in general, to provide a runnable test case illustrating your issue.

    An easy way to get started with simplified code samples is by using one of the examples in our Ext.NET 5 Examples Explorer as a base to draft the scenario you're trying to showcase. This might be a good one that can be extended to check the nodes, and already has a bit of depth in the nodes: Tree Panel > Basic > Checkbox_Nodes.

    Last, here are some guidelines on posting new threads in a way that helps us provide you a better, and faster answer:

    - Tips for creating simplified code samples
    - More Information Required
    - Forum Guidelines

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Replies: 2
    Last Post: Jan 29, 2016, 9:19 PM
  2. Replies: 20
    Last Post: Dec 16, 2010, 11:02 AM
  3. set ext:checkbox select/unselect
    By Rupesh in forum 1.x Help
    Replies: 1
    Last Post: Dec 14, 2010, 11:42 AM
  4. [CLOSED] Grid Panel Select and Unselect Issue
    By speedstepmem3 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 06, 2010, 9:39 AM
  5. Grid panel one group select all
    By anilkumar in forum 1.x Help
    Replies: 0
    Last Post: Jun 13, 2009, 4:18 AM

Tags for this Thread

Posting Permissions