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:
The code-behind:
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(); |
| } |
| } |