PDA

View Full Version : Dynamically add select all and unselect all to group in ext



avair
May 15, 2023, 8:12 AM
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>

fabricio.murta
May 16, 2023, 2:02 AM
Hello, @avair, and welcome to Ext.NET forums!

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

- Treepanel cascade check (https://forums.ext.net/showthread.php?13047-CLOSED-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
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 (https://examples5.ext.net) 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 (https://examples5.ext.net/#/TreePanel/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 (http://forums.ext.net/showthread.php?61176-Tips-for-creating-simplified-code-samples)
- More Information Required (http://forums.ext.net/showthread.php?10205-More-Information-Required)
- Forum Guidelines (http://forums.ext.net/showthread.php?3440-Forum-Guidelines-For-Posting-New-Topics)

Hope this helps!