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

To group but not to group

4 Answers 160 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sidharth
Top achievements
Rank 1
Sidharth asked on 26 May 2014, 08:35 AM
Hi,

I would like to set a default group on a rad grid but not allow users to change it. Therefore, I do not want to see the group panel at the top of the grid but still display the actual grouping row in the grid itself. (I hope that is clear!) 

This is what I currently have:

                <telerik:RadGrid ID="rgAdditionalPermissions" runat="server" DataSourceID="odsAdditionalPermissions" GroupingEnabled="true" ShowGroupPanel="false" ClientSettings-AllowDragToGroup="false">
                    <GroupingSettings ShowUnGroupButton="false" />
                    <GroupPanel Enabled="false"></GroupPanel>
                    <MasterTableView AutoGenerateColumns="False" DataSourceID="odsAdditionalPermissions" DataKeyNames="RightId">
                        <CommandItemSettings ExportToPdfText="Export to PDF" />
                        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                            <HeaderStyle Width="20px" />
                        </RowIndicatorColumn>
                        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                            <HeaderStyle Width="20px" />
                        </ExpandCollapseColumn>
                        <GroupByExpressions>
                            <telerik:GridGroupByExpression>
                            <SelectFields>
                                <telerik:GridGroupByField FieldName="RightCategoryName" HeaderText="Category" />
                            </SelectFields>
                            <GroupByFields>
                                <telerik:GridGroupByField FieldName="RightCategoryName" SortOrder="Descending" />
                            </GroupByFields>
                            </telerik:GridGroupByExpression>
                        </GroupByExpressions>
                        <Columns>
                            <telerik:GridBoundColumn DataField="RightName" FilterControlAltText="Filter RightName column" HeaderText="Permission" SortExpression="RightName" UniqueName="RightName">
                            </telerik:GridBoundColumn>
                            <telerik:GridTemplateColumn>
                                <ItemTemplate>
                                    <asp:CheckBox ID="chkSelected" runat="server" Checked='<%# Bind("Active") %>'/>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                        </Columns>
                        <EditFormSettings>
                            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                            </EditColumn>
                        </EditFormSettings>
                    </MasterTableView>
                    <FilterMenu EnableImageSprites="False">
                    </FilterMenu>
                    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
                    </HeaderContextMenu>

                </telerik:RadGrid>




If I want the rows of the Grid to be grouped then I have to set GroupingEnabled="true" but despite setting all others, like ShowGroupPanel to false, it still displays the group panel. 

Is it possible to do what I would like RadGrid to do? And if so do you know how I would go about implementing it?

Kind regards
Sidharth


4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 26 May 2014, 12:44 PM
Hi Sidharth,

When you set ShowGroupPanel="false" the Group panel is not shown. I was not able to replicate your issue at my end. In the case you want to prevent the Ungrouping of a Field, you can try the following code snippet.

C#:
protected void RadGrid1_GroupsChanging(object sender, GridGroupsChangingEventArgs e)
{
  if (e.Action == GridGroupsChangingAction.Ungroup)
  {
    if (e.Expression.GroupByFields[0].FieldName == "RightCategoryName")
    {
      e.Canceled = true;
    }
  }
}

Thanks,
Shinu
0
Sidharth
Top achievements
Rank 1
answered on 27 May 2014, 04:05 PM
Hi Shinu,

Thanks for your reply.

Unfortunately I don't know why it's not happening for me. So I have this:

                <telerik:RadGrid ID="rgAdditionalPermissions" runat="server" DataSourceID="odsAdditionalPermissions" GroupingEnabled="true" ShowGroupPanel="false">
                    <MasterTableView AutoGenerateColumns="False" DataSourceID="odsAdditionalPermissions" DataKeyNames="RightId">
                        <CommandItemSettings ExportToPdfText="Export to PDF" />
                        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                            <HeaderStyle Width="20px" />
                        </RowIndicatorColumn>
                        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                            <HeaderStyle Width="20px" />
                        </ExpandCollapseColumn>
                        <GroupByExpressions>
                            <telerik:GridGroupByExpression>
                            <SelectFields>
                                <telerik:GridGroupByField FieldName="RightCategoryName" HeaderText="Category" />
                            </SelectFields>
                            <GroupByFields>
                                <telerik:GridGroupByField FieldName="RightCategoryName" SortOrder="Descending" />
                            </GroupByFields>
                            </telerik:GridGroupByExpression>
                        </GroupByExpressions>
                        <Columns>
                            <telerik:GridBoundColumn DataField="RightName" FilterControlAltText="Filter RightName column" HeaderText="Permission" SortExpression="RightName" UniqueName="RightName">
                            </telerik:GridBoundColumn>
                            <telerik:GridTemplateColumn>
                                <ItemTemplate>
                                    <asp:CheckBox ID="chkSelected" runat="server" Checked='<%# Bind("Active") %>'/>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                        </Columns>
                        <EditFormSettings>
                            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                            </EditColumn>
                        </EditFormSettings>
                    </MasterTableView>
                    <FilterMenu EnableImageSprites="False">
                    </FilterMenu>
                    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
                    </HeaderContextMenu>

                </telerik:RadGrid>

But setting showgrouppanel = false doesn't hide the top group panel. If I make GroupingEnabled = false then the group panel disappears but obviously the grouping that I have set in the aspx is also removed.


0
Sidharth
Top achievements
Rank 1
answered on 27 May 2014, 04:09 PM
Sorry, sent the previous post too quickly. So in the attached images I would like the "Category: ABCDE" to still appear but I do not want the green "Category" button/panel to be visible at the top of the radgrid. Are the settings that I am setting incorrect? Should I be setting something else?

Kind regards
Sidharth
0
Shinu
Top achievements
Rank 2
answered on 28 May 2014, 07:16 AM
Hi Sidharth,

I was not able to replicate such an issue at my end. Make sure in code behind you have not set ShowGroupPanel as true. Here is a sample code snippet please try and check if the issue exist.

ASPX:
<telerik:RadGrid ID="RadGridSample" runat="server" DataSourceID="SqlDataSource1" AllowSorting="true" AllowPaging="true">
    <MasterTableView AutoGenerateColumns="False" DataKeyNames="OrderID">
        <GroupByExpressions>
            <telerik:GridGroupByExpression>
                <SelectFields>
                    <telerik:GridGroupByField FieldName="ShipCity" HeaderText="ShipCity" />
                </SelectFields>
                <GroupByFields>
                    <telerik:GridGroupByField FieldName="ShipCity" SortOrder="Descending" />
                </GroupByFields>
            </telerik:GridGroupByExpression>
        </GroupByExpressions>
        <Columns>
            <telerik:GridBoundColumn DataField="OrderID" HeaderText="OrderID" SortExpression="OrderID" UniqueName="OrderID">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="ShipName" HeaderText="ShipName" SortExpression="ShipName" UniqueName="ShipName">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Freight" HeaderText="Freight" SortExpression="Freight" UniqueName="Freight">
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"  SelectCommand="SELECT  * FROM [Orders]"></asp:SqlDataSource>

Thanks,
Shinu
Tags
Grid
Asked by
Sidharth
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Sidharth
Top achievements
Rank 1
Share this question
or