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

Display RadGrid items in grouping as ListView layout

1 Answer 66 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ali
Top achievements
Rank 1
Ali asked on 02 Oct 2012, 09:35 PM
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 items are shown under corresponding Grouping.
I know the layout may seem impossible for RadGrid, but I believe it's possible, though I haven't figured out how? Does anyone know how to do it as I need it badly [without using ListView, only RadGrid]. Please see my code below.

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


<%@ 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>

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 05 Oct 2012, 03:24 PM
Hi,

As my colleague Tsvetina said to you in the other thread that you have opened, that required layout could not be achieved with RadGrid,

If you want to achieve the desired layout you will need to reiimplement half the logic of RadGrid and finally you will get the implementation of RadListView.


Regards,
Andrey
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
Andrey
Telerik team
Share this question
or