+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Adding Theme to Pages Grid

Adding Theme to Pages Grid

4 posts, 0 answered
  1. Derek Mebus
    Derek Mebus avatar
    1 posts
    Registered:
    15 Mar 2010
    15 Mar 2010
    Link to this post
    How can I add a column to the Pages grid that shows each page's theme?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    15 Mar 2010
    Link to this post
    Hello Derek Mebus,

    1. Open ~/Sitefinity/Admin/ControlTemplates/Pages/AllPagesList.ascx
    2. Add TemplateField with a Label control

    <asp:TemplateField HeaderText="Theme" SortExpression="Theme">
                   <ItemStyle CssClass="gridContentTitle" />
                   <ItemTemplate>
                       <asp:Label runat="server" ID="ThemeLabel"></asp:Label>
                   </ItemTemplate>
    </asp:TemplateField>

    3. Subscribe for RowCreated of the RadGrid control on Page_Load and implement the logic below.

    public void Page_Load(object sender, EventArgs e)
       {
           GridView1.RowCreated += new GridViewRowEventHandler(GridView1_RowCreated);
       }
     
       void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
       {
           if (e.Row.DataItem != null)
           {
               Telerik.Cms.CmsPageInfo info = e.Row.DataItem as Telerik.Cms.CmsPageInfo;
               string pageTheme = info.CmsPage.Theme;
               Label lbl = e.Row.FindControl("ThemeLabel") as Label;
               if (lbl != null)
               {
                   lbl.Text = pageTheme;
               }
           }
       }


    Best wishes,
    Ivan Dimitrov
    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.
  3. Petr
    Petr avatar
    34 posts
    Registered:
    03 Jan 2011
    04 Mar 2011
    Link to this post
    Hi,

    please, can you let me know, how to add codefile (and PageLoad method) to AllPagesList.ascx? I've tried it (like for news, where it works), but without success.

    Thanks

    Petr
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    04 Mar 2011
    Link to this post
    Hello Petr,

    You can just write the code in the template using <script> block.

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Register for webinar
4 posts, 0 answered