This is a migrated thread and some comments may be shown as answers.

Grouping - only first group and his first item shown

4 Answers 211 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Harun
Top achievements
Rank 1
Harun asked on 02 Jul 2011, 05:51 PM
Hi,

i have an issue with the grouping functionality of RadGrid.
There is a grid with several items.
Each element is custom object and is bind via "RadGrid.Datasource".
Everything works fine and all items are shown in the Grid if there is no grouping.
But after i am enabling grouping and set following SelectFields & GroupByFields only the first group and his first element is shown in the grid.
<GroupByExpressions>
    <telerik:GridGroupByExpression>
        <SelectFields>
            <telerik:GridGroupByField FieldAlias="Bundle" FieldName="GroupName" HeaderValueSeparator="_" />
        </SelectFields>
        <GroupByFields>
            <telerik:GridGroupByField FieldName="GroupName" SortOrder="None"/>
        </GroupByFields>
    </telerik:GridGroupByExpression>
</GroupByExpressions>

I use the debugger and search for an error but everything looks fine and all items are bind to the datasource.
But only the first group is shown in the grid and from this first group only the first item.
The title of the group is like "Bundle_Truck7546 (Showing 1 of 3 items. Group continues on the next page.)" but the PageSize is at 50 and there is no next page.

I hope anyone know what cause this problem and how i can solve it.

If you need further information please post.

best regards

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 04 Jul 2011, 05:30 AM
Hello Harun,

The GroupByFields collection determines the field values that are used to group the data. In order to show grouping for all items, try setting the aspx as shown below.

aspx:
<GroupByExpressions>
    <telerik:GridGroupByExpression>
        <SelectFields>
            <telerik:GridGroupByField FieldName="GroupName" SortOrder="None"/>      
            <telerik:GridGroupByField FieldAlias="Bundle" FieldName="GroupName" HeaderValueSeparator="_" />
        </SelectFields>
        <GroupByFields>
            <telerik:GridGroupByField FieldName="GroupName" SortOrder="None"/>
        </GroupByFields>
    </telerik:GridGroupByExpression>
</GroupByExpressions>

Also check the following help documentation which explains the same.
Declarative definition.

Thanks,
Princy.
0
Harun
Top achievements
Rank 1
answered on 04 Jul 2011, 10:30 AM
Hi Princy,

thanks for your fast reply. My problem is not solved with the additional statement.
Although only first group and first element are shown.
For more details i´m posting my column declarations.
I only want to group all items related to the GroupName Column.

<telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        function confirmFnResetAsset(args) {
            if (args) {
                doResetPostBack("ConfirmAction");
            } else {
                doResetPostBack("DenyAction");
            }
        }
        function CollapseAll(event) {
            var tableView = $find('<%=RadGrid1.ClientID %>').get_masterTableView();
            var rows = tableView.get_element().rows;
            for (var i = 0, len = tableView.get_element().rows.length; i < len; i++) {
                var button = tableView._getGroupExpandButton(rows[i]);
                if (button) {
                    var groupLevel = button.id.split("__")[2];
                    if (groupLevel == 0) {
                        tableView._toggleGroupsExpand(button, event);
                    }
                }
            }
        }
    </script>
</telerik:RadCodeBlock>
<telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource"
    OnItemCommand="RadGrid1_ItemCommand" OnItemDataBound="RadGrid1_ItemDataBound"
    OnItemCreated="RadGrid1_ItemCreated" AllowFilteringByColumn="True" EnableLinqExpressions="False"
    AutoGenerateColumns="False" AllowPaging="True" PageSize="50" Width="100%" PagerStyle-Mode="NextPrevAndNumeric"
    AllowCustomPaging="True" ShowFooter="true" PagerStyle-AlwaysVisible="true"
    PagerStyle-Position="Bottom" GridLines="None" GroupingSettings-CaseSensitive="false">
    <HeaderContextMenu>
        <CollapseAnimation Duration="200" Type="OutQuint" />
    </HeaderContextMenu>
    <ExportSettings FileName="HandOverAssets" IgnorePaging="True" ExportOnlyData="true" />
    <MasterTableView GroupLoadMode="Client" CommandItemDisplay="Top">
        <GroupByExpressions>
            <telerik:GridGroupByExpression>
                <SelectFields>
                    <telerik:GridGroupByField FieldName="GroupName"/>
                    <telerik:GridGroupByField FieldAlias="Bundle" FieldName="GroupName" HeaderValueSeparator="_" />
                </SelectFields>
                <GroupByFields>
                    <telerik:GridGroupByField FieldName="GroupName" SortOrder="Ascending" />
                </GroupByFields>
            </telerik:GridGroupByExpression>
        </GroupByExpressions>
                <CommandItemTemplate>
            <div style="float: right; margin-right: 5px; margin-top:5px; height: 25px;">
                <asp:LinkButton ID="LinkButtonClearFilter" runat="server" CommandName="ClearFilters" Style="margin-top: 10px; margin-left: 10px;">
                    <asp:Image ID="ImageClearFilters" runat="server" ImageUrl="~/img/Grid.CommandItem.ClearFilters.png" />
                    <asp:Literal ID="LitClearFilters" runat="server" Text="" />
                </asp:LinkButton>
            </div>
        </CommandItemTemplate>
        <Columns>
            <telerik:GridBoundColumn DataField="HandOverDateTime" UniqueName="HandOverDateTime"
                AllowFiltering="false" Visible="false" />
            <telerik:GridBoundColumn DataField="AssetSk" UniqueName="SerialNum" Visible="false" />
            <telerik:GridBoundColumn DataField="AssetFound" UniqueName="AssetFound" Visible="false" />
            <telerik:GridBoundColumn HeaderText="<%$ Resources:handoverassets, LblSerialNum %>"
                HeaderButtonType="TextButton" DataField="SerialNumber" UniqueName="SerialNumber"
                ItemStyle-Font-Size="Smaller" FilterControlWidth="100%" CurrentFilterFunction="Contains"
                ShowFilterIcon="false" AutoPostBackOnFilter="true" />
            <telerik:GridBoundColumn HeaderText="<%$ Resources:handoverassets, LblClass %>" HeaderButtonType="TextButton"
                DataField="Class" UniqueName="Class" ItemStyle-Font-Size="Smaller" FilterControlWidth="100%"
                CurrentFilterFunction="Contains" ShowFilterIcon="false" AutoPostBackOnFilter="true" />
            <telerik:GridBoundColumn HeaderText="<%$ Resources:handoverassets, LblModel %>" HeaderButtonType="TextButton"
                DataField="Model" UniqueName="Model" ItemStyle-Font-Size="Smaller" FilterControlWidth="100%"
                CurrentFilterFunction="Contains" ShowFilterIcon="false" AutoPostBackOnFilter="true" />
            <telerik:GridBoundColumn HeaderText="<%$ Resources:handoverassets, LblGroupName %>"
                HeaderButtonType="TextButton" DataField="GroupName" UniqueName="GroupName" ItemStyle-Font-Size="Smaller"
                FilterControlWidth="100%" CurrentFilterFunction="Contains" ShowFilterIcon="false"
                AutoPostBackOnFilter="true" />
            <telerik:GridTemplateColumn HeaderText="<%$ Resources: handoverassets, LblHwOption %>"
                UniqueName="HwOption" AllowFiltering="false">
                <ItemTemplate>
                    <asp:CheckBox ID="ChkBxHwOption" runat="server" Enabled="false" />
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn AllowFiltering="false" UniqueName="LnkBtnRemoveAssetColumn">
              <ItemTemplate>
                    <asp:LinkButton ID="LnkBtnRemoveAsset" runat="server" Text="Remove" OnClick="LnkBtnRemoveAssetClick"
                        CommandArgument='<%# Eval("SerialNumber") %>'>
                        <span>
                            <asp:Image ID="ImgRemove" runat="server" ImageUrl="~/img/buttonGridItemCancel.gif" />
                        </span>
                    </asp:LinkButton>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
    </MasterTableView>
    <ClientSettings AllowGroupExpandCollapse="True">
        <ClientEvents OnGridCreated="CollapseAll" />
    </ClientSettings>
</telerik:RadGrid>

I hope for further suggestions to solve the problem.

best regards
0
Harun
Top achievements
Rank 1
answered on 04 Jul 2011, 12:40 PM
Hi,

for those who also have the same issue.
The problem was caused by the property AllowCustomPaging="True"
Because of the custom paging not all items were shown in the grid.
This property is as default "false" and should be let how it is ;)

best regards

0
sukhwinder
Top achievements
Rank 1
answered on 18 May 2017, 03:11 PM

for me it happened cause i had custom paging and i was not setting VirtualItemCount properly. 

 

Tags
Grid
Asked by
Harun
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Harun
Top achievements
Rank 1
sukhwinder
Top achievements
Rank 1
Share this question
or