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

Grid / ListView/DataList View with Grouping

5 Answers 178 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ali
Top achievements
Rank 1
Ali asked on 14 Sep 2012, 08:43 AM
Hi,
I am trying to use RadGrid as ListView layout and was able to follow the demo below to achieve the results.

Grid / ListView/DataList View:
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/listview/defaultcs.aspx 

Now, I need to be able to use "Grouping" [using ContactTitle:] so that all the ListView items are shown under corresponding Grouping.
Is it possible and if so how?

Thanks for your help.
http://www.megasearches.com/ 

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 14 Sep 2012, 09:18 AM
Hi,

You can set GridGroupByExpression as shown below.
aspx:
<GroupByExpressions>
     <telerik:GridGroupByExpression>
            <SelectFields>
                  <telerik:GridGroupByField FieldName="ContactTitle" />
            </SelectFields>
              <GroupByFields>
                     <telerik:GridGroupByField FieldName="ContactTitle"  />
             </GroupByFields>
     </telerik:GridGroupByExpression>
</GroupByExpressions>
Also check the following demo which explains more about grouping.
Grid / Outlook-style Grouping

Thanks,
Shinu.
0
Ali
Top achievements
Rank 1
answered on 16 Sep 2012, 02:56 AM
Hi,
I tried the <GroupByExpressions> but it did not work quite the way I want. Please see the attached images "gridlayout_current.jpg" and "gridlayout_expected.jpg".

---------------------------------------------------------------------- 
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="MainGrid_Box.ascx.cs" Inherits="_Default_MainGrid_Box" %>
 
<telerik:RadGrid ID="RadGrid_r2bweb_Box" GridLines="None" runat="server" AllowSorting="true" AllowPaging="false" DataSourceID="SqlDataSource_r2bweb_Box">
    <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true"/>
    <MasterTableView Width="100%" CommandItemDisplay="Top" DataKeyNames="url_id"
        DataSourceID="SqlDataSource_r2bweb_Box" HorizontalAlign="NotSet" AutoGenerateColumns="true"
        GroupLoadMode="Client" GroupsDefaultExpanded="true" TableLayout="Fixed">
        <GroupHeaderTemplate>
            <asp:CheckBox ID="CheckBox_Main_Box" runat="server" onclick="CheckAll(this);" />
            <asp:Label runat="server" ID="r2b_GroupingHeader_Main_Box" Text='<%# " lst_name(s): "+Eval("lst_name") %>'
            Visible='<%# ((((GridGroupHeaderItem)Container).AggregatesValues["lst_name"]) != null)%>'></asp:Label>
        </GroupHeaderTemplate>
        <GroupByExpressions>
            <telerik:GridGroupByExpression>
                <SelectFields>
                    <telerik:GridGroupByField FieldAlias="lst_name" FieldName="lst_name"></telerik:GridGroupByField>
                </SelectFields>
                <GroupByFields>
                    <telerik:GridGroupByField FieldName="lst_name" SortOrder="Descending"></telerik:GridGroupByField>
                </GroupByFields>
            </telerik:GridGroupByExpression>
        </GroupByExpressions>
        <ItemTemplate>
            <%# (((GridItem)Container).ItemIndex != 0)? "</td></tr></table>" : "" %>
            <asp:Panel ID="r2bweb_panel" CssClass='<%# (((GridItem)Container).ItemType == GridItemType.Item)? "item" : "alternatingItem" %>' HorizontalAlign="Center" runat="server">
                <asp:Image ID="r2bweb_mySites" Style="float: left; text-align:center;" Width="50px" Height="50px" ImageUrl="~/Images/mySites.png" runat="server" AlternateText="My Site" />
                <br />
                <%# Eval("url_name")%>
            </asp:Panel>
        </ItemTemplate>   
    </MasterTableView>
    <ClientSettings AllowDragToGroup="false" AllowColumnsReorder="false" AllowRowsDragDrop="True"
    AllowGroupExpandCollapse="True">
        <Selecting AllowRowSelect="true" EnableDragToSelectRows="true" />
        <Resizing AllowRowResize="True" EnableRealTimeResize="false" ResizeGridOnColumnResize="false"            
        AllowColumnResize="True" AllowResizeToFit="true" ShowRowIndicatorColumn="false"
        ClipCellContentOnResize="false" />
        <Scrolling AllowScroll="false" UseStaticHeaders="True" SaveScrollPosition="true" />
    </ClientSettings>
</telerik:RadGrid>
<asp:SqlDataSource ID="SqlDataSource_r2bweb_Box" runat="server"
ConnectionString="<%$ ConnectionStrings:r2bweb_ConnectionString %>"
    SelectCommand="SELECT a.[lst_id], b.[lst_name], a.[url_id], a.[urp_id], a.[usr_id], a.[cat_id], a.[url_isOpen], a.[url_type], a.[url_name], a.[url_address], a.[url_isLoginOrOpen], a.[url_username], a.[url_isSaveUsername], a.[url_isEnableUsername], a.[url_password], a.[url_isSavePassword], a.[url_isEnablePassword], a.[url_desc], a.[url_isSave] FROM [t_url] a INNER JOIN [t_myList] b ON a.[lst_id] = b.[lst_id]">
</asp:SqlDataSource>
---------------------------------------------------------------------- 

Your help regarding this will be highly appreciated.

Thanks,
http://www.megasearches.com/ 


0
Tsvetina
Telerik team
answered on 19 Sep 2012, 07:11 AM
Hello,

The required layout cannot be achieved with a table-like structure like RadGrid's. You should rather use RadListView with grouping to achieve your goal:
http://demos.telerik.com/aspnet-ajax/listview/examples/grouping/defaultcs.aspx

Greetings,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Ali
Top achievements
Rank 1
answered on 20 Sep 2012, 10:14 PM
Hi Tsvetina,
Thanks for your response. But my project requires that I use a RadGrid in both views not RadListView so that both the controls are the same but views are different. Is there any workaround to this?

Once again, thanks for your help.
http://www.megasearches.com/  

0
Tsvetina
Telerik team
answered on 25 Sep 2012, 12:30 PM
Hi,

Your required layout cannot be achieved in a grouped RadGrid. A last option would be if you could use a hierarchical structure with a NestedViewTemplate but I assume this would make this RadGrid instance too different from the other.

Kind regards,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Ali
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Ali
Top achievements
Rank 1
Tsvetina
Telerik team
Share this question
or