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

RadGrid Grouping Issue

1 Answer 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin Kurtz
Top achievements
Rank 1
Kevin Kurtz asked on 19 Apr 2010, 11:17 PM
Hello,

It seems I am having an issue with the grid adding un-needed functionality to my grid.  Specifically, I am trying to create an list of news articles, sorted by month (Jan, Feb, etc.) with the articles listed within each month.  I am NOT using skins for the control, and instead, using standard HTML code to format the list since our site is not using anything fancy at this moment.

What I would like to do is not have the button to allow the expanding/collapsing of the categories (see attached screen shot).  I tried using the documentation at this link (http://www.telerik.com/help/aspnet-ajax/grdpreventgroupsexpansion.html)  but it seems as though the code behind is not being read at runtime.  I am putting my code below so you can see how I have done this.  A quick response is greatly appreciated.  Thank you!

Kevin

The HTML:
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server"
    </telerik:RadScriptManager> 
        <telerik:RadGrid  
        ID="gridNews" 
        runat="server"  
        AutoGenerateColumns="false"  
        ShowHeader="false" EnableEmbeddedSkins="False"
<HeaderContextMenu EnableEmbeddedSkins="False"></HeaderContextMenu> 
 
        <MasterTableView DataKeyNames="NewsID" GroupLoadMode="Server"
                <GroupByExpressions>         
                    <telerik:GridGroupByExpression> 
                        <SelectFields> 
                            <telerik:GridGroupByField FieldName="MonthYear" HeaderText=" " SortOrder="None"></telerik:GridGroupByField>                                                         
                        </SelectFields> 
                        <GroupByFields> 
                            <telerik:GridGroupByField FieldName="MonthYear" HeaderText=" " SortOrder="Descending"></telerik:GridGroupByField>                            
                        </GroupByFields> 
                    </telerik:GridGroupByExpression>            
                </GroupByExpressions> 
            <Columns> 
            <telerik:GridTemplateColumn HeaderText="Date" GroupByExpression="Month Date Group By Month" DataType="System.DateTime" > 
            <ItemTemplate> 
            <b> 
                <asp:Label ID="Label1" runat="server" Text='<%# Eval("dtNewsDate") %>' DataType="System.DateTime" ></asp:Label></b
                <p> 
                    <b> 
                        <asp:Label ID="lblPublication" runat="server" Text='<%# Eval("strPublication") %>'></asp:Label></b><br /> 
                    <b> 
                        <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("strArticleLink") %>' 
                            Target="_blank"
                            <asp:Label ID="lblArticleTitle" runat="server" Text='<%# Eval("strArticleTitle") %>'></asp:Label> 
                        </asp:HyperLink></b
                    <br /> 
                    <asp:Label ID="lblArticleSynopsis" runat="server" Text='<%# Eval("strArticleSynopsis") %>'></asp:Label> 
                    <br /> 
                </p> 
            </ItemTemplate> 
            </telerik:GridTemplateColumn> 
            </Columns> 
 
<EditFormSettings> 
<EditColumn InsertImageUrl="Update.gif" UpdateImageUrl="Update.gif" EditImageUrl="Edit.gif" CancelImageUrl="Cancel.gif"></EditColumn> 
</EditFormSettings> 
        </MasterTableView> 
 
            <ClientSettings AllowExpandCollapse="False"
                <Resizing AllowColumnResize="True" /> 
            </ClientSettings> 
 
<FilterMenu EnableEmbeddedSkins="False"></FilterMenu> 
    </telerik:RadGrid> 

The code-behind:
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using Telerik.Web.UI; 
 
public partial class AboutUs_NewsRoom_News : System.Web.UI.Page 
    protected void Page_Load(object sender, EventArgs e) 
    { 
        Master.imgHeroTitle = "~/img/hero-news.gif"
        Master.HeroClass = "hero_"
        ucAboutNav1.NewsPanel = true
 
        if (!IsPostBack) 
        { 
            LoadGrid(); 
        } 
 
    } 
    public void LoadGrid() 
    { 
        gridNews.DataSource = new List<string>(0); 
        gridNews.DataBind(); 
        gridNews.DataSource = MainName.core.CMS.News.GetNewsList(); 
        gridNews.DataBind(); 
 
        MainName.core.CMS.News n = new MainName.core.CMS.News(); 
        n.dtNewsDate.Month.ToString(); 
    } 
 
    protected void gridNews_ColumnCreated(object sender, GridColumnCreatedEventArgs e) 
    { 
        if (e.Column is GridGroupSplitterColumn) 
        { 
            e.Column.HeaderStyle.Width = Unit.Pixel(1); 
            e.Column.HeaderStyle.Font.Size = FontUnit.Point(1); 
            e.Column.ItemStyle.Width = Unit.Pixel(1); 
            e.Column.ItemStyle.Font.Size = FontUnit.Point(1); 
            e.Column.Resizable = false
        } 
    } 
    protected void gridNews_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridGroupHeaderItem) 
        { 
            (e.Item as GridGroupHeaderItem).Cells[0].Controls.Clear(); 
        } 
    } 

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 21 Apr 2010, 12:00 PM
Hello Kevin,

Please, note that simple data-binding through the DataBind() method can be used in simple scenarios which do not require the grid to perform complex operations such as grouping. Therefore, I suggest that you bind the Grid using AdvanceDataBinding techniques. In this way, you could disable the GridGroupSplitterColumn so that users can't collapse the groups in a grid as described in the help article below:
Preventing groups expansion by hiding the expand/collapse images

Additionally, I noticed that you have opened a duplicate post on the same matter. Please, refer to the other support ticket post for additional information. To avoid duplicate posts, we can continue our communication there.

Kind regards,
Pavlina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Kevin Kurtz
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or