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

Forums / Developing with Sitefinity / Download list remove columns

Download list remove columns

11 posts, 1 answered
  1. Rabindra
    Rabindra avatar
    106 posts
    Registered:
    17 May 2009
    07 Dec 2009
    Link to this post
    Hi,
       I have added a download list. I wanted to remove 2 columns "Author" and "Tags". By going to Edit and Setting, I unchecked Author and Tags. I don't see them but the column heading is still visible.
    Which .ascx file do I need to edit manually?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    07 Dec 2009
    Link to this post
    Hi Rabindra,

    The template has the following structure

    <asp:Repeater ID="repeater" runat="server">
        <HeaderTemplate>
            <table class="sf_libraryGrid">
                <thead>
                <tr>
                    <th scope="col" id="TitleWrap" runat="server"><asp:Literal ID="Literal1" runat="server" Text="<%$Resources:Items_Title %>"></asp:Literal></th>
                    <th scope="col" id="ExtWrap" runat="server"><asp:Literal ID="Literal2" runat="server" Text="<%$Resources:Items_Extension %>"></asp:Literal></th>
                    <th scope="col" id="AuthorWrap" runat="server"><asp:Literal ID="Literal3" runat="server" Text="<%$Resources:Items_Author %>"></asp:Literal></th>
                    <th scope="col" id="UploadDateWrap" runat="server"><asp:Literal ID="Literal4" runat="server" Text="<%$Resources:Items_UploadDate %>"></asp:Literal></th>
                    <th scope="col" id="SizeWrap" runat="server"><asp:Literal ID="Literal5" runat="server" Text="<%$Resources:Items_Size %>"></asp:Literal></th>
                    <th scope="col" id="TagWrap" runat="server"><asp:Literal ID="Literal6" runat="server" Text="<%$Resources:Items_Tags %>"></asp:Literal></th>
                    <th scope="col" id="DownloadLinkWrap" runat="server"></th>
                </tr>
                </thead>
                <tbody>
        </HeaderTemplate>
     
     . . . .
       . . . .

    As you can see this is a table. The TextSettings control from the DownloadList control designer does not remove three header cells. There are two options here.

    1. Map the external template DownloadListTableMode.ascx and just remove this three header cells from the declaration.

    2. Create a custom control that inherits from DownloadList control. Then override CreateChildControls. Access the <th> element by ID and hide it. You can create a public property of boolean type that you will be able to set from the control designer.

    public class CustomDownloadListToolboxItem : Telerik.Web.ToolboxItem
    {
     
        public CustomDownloadListToolboxItem()
            : base(typeof(CustomDownloadList))
        {
            base.DisplayName = "DisplayName";
            base.Description = "DownloadList_Description";
        }
    }
     
     
     
    [System.ComponentModel.ToolboxItem(typeof(CustomDownloadListToolboxItem))]
    [ControlDesignerAttribute("DownloadListControlDesigner, App_Code")]
    public class CustomDownloadList : DownloadList
    {
        public CustomDownloadList()
        {
     
        }
     
        public override string ItemListTemplatePath
        {
            get
            {
                return "~/Sitefinity/Admin/ControlTemplates/Libraries/Dialogs/DownloadListTableMode.ascx";
            }
     
        }
     
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            ListContainer.RepeaterControl.ItemDataBound += new RepeaterItemEventHandler(RepeaterControl_ItemDataBound);
         
     
        }
     
        void RepeaterControl_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Header || e.Item.ItemType == ListItemType.Item)
            {
                // hide the <th> after you find it by ID.
                // id="AuthorWrap"
            }
        }
    }


    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Answered
  3. Rabindra
    Rabindra avatar
    106 posts
    Registered:
    17 May 2009
    07 Dec 2009
    Link to this post
    Hi Ivan,
      I implemented your first method.
    thanks
  4. Bart Welch
    Bart Welch avatar
    64 posts
    Registered:
    10 Jul 2009
    22 Apr 2010
    Link to this post
    Where is this template located?
  5. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    23 Apr 2010
    Link to this post
    Hello Bart Welch,

    You should first download the external templates archive from your Client.Net account. If you have doubts on how to work with external templates, please consult with this KB article: http://www.sitefinity.com/support/kb/sitefinity-3-x/how-to-map-a-view-to-an-external-template-in-sitefinity-3-6-or-later.aspx. After you have extracted the archive, you will be able to find the template in ~/Sitefinity/Admin/ControlTemplates/Libraries/Modes/

    Regards,
    Radoslav Georgiev
    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.
  6. Snehal Mehta
    Snehal Mehta avatar
    8 posts
    Registered:
    31 May 2010
    25 May 2011
    Link to this post
    Hi,

    I am trying to customize the DownloadList with different set of columns on different pages. I tried to go to settings and uncheck Author and Tags column for a particular page. But the header is still being displayed.

    If I implement the solution you suggested to override the template, then Author and Tags will be permanently removed from all the downlists I used on different pages.

    Could you help me with a solution that will allow me to show/hide columns with their headings differently on different pages.

    Regards
    Snehal
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    25 May 2011
    Link to this post
    Hello ,


    You can map the template directly through control designer, so this will affect only the current instance of the control and all other controls will use the old template.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  8. Snehal Mehta
    Snehal Mehta avatar
    8 posts
    Registered:
    31 May 2010
    26 May 2011
    Link to this post
    Thanks Ivan,

    I have created custom control for table view.

    1. I am trying to add custom event to repeater event for ItemDataBound, but it doesn't work. I tried to trace it, but it never gets into RepeaterControl_itemDataBound.

        
    protected override void CreateChildControls()
    {
        base.CreateChildControls();
        this.ListContainer.RepeaterControl.ItemDataBound += new RepeaterItemEventHandler(RepeaterControl_ItemDataBound);
    }
     
    public void RepeaterControl_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Header || e.Item.ItemType == ListItemType.Item)
        {
             
            var authorwrap = e.Item.FindControl("AuthorWrap") as TableHeaderRow;
            authorwrap.Visible = false;
            // hide the <th> after you find it by ID.
            // id="AuthorWrap"
     
        }
    }
               

    2. Is there a way in the override CreateChildControls method to find out which columns are hidden through the sitefinity settings? If I can get that, then I can hide only those column headings that are unchecked from the settings.
    Because right now, if I uncheck Author and Tags column from the sitefinity settings, I don't see the data but only column headings. So if there is a method by which I can find which columns are hidden, I could hide appropriate column headings.

    Regards
    Snehal
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    26 May 2011
    Link to this post
    Hello ,

    I checked the code an it runs fine. Can you check whether CreateChildControls is called, not the itemDataBound?

    The table is defined in the template of the repeater, so you can access the items only in ItemDataBound event that is properly fired at my end.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  10. Snehal Mehta
    Snehal Mehta avatar
    8 posts
    Registered:
    31 May 2010
    27 May 2011
    Link to this post
    Hi Ivan,

    1. If not from ItemDataBound, is it possible from CreateChildControls to know what columns are hidden through settings? I just want a way to know what columns are hidden through settings, so that I can hide the table headings appropriately.

    2. Following is the code that I have. It triggers CreateChildControl method, but never triggers RepeaterControl_ItemDataBound.

    public class CustomDownloadListToolboxItem : Telerik.Web.ToolboxItem
        {
     
            public CustomDownloadListToolboxItem()
                : base(typeof(DownloadListTable))
            {
                base.DisplayName = "Downloadlist_Table";
                base.Description = "DownloadList_Customised_Table";
            }
        }
     
        [System.ComponentModel.ToolboxItem(typeof(CustomDownloadListToolboxItem))]
        public class DownloadListTable : DownloadList
        {
            public DownloadListTable()
            {
            }
     
            public override string ItemListTemplatePath
            {
                get
                {
                    return "~/Sitefinity/ControlTemplates/Libraries/DownloadListTable.ascx";
                }
     
            }
     
            protected override void CreateChildControls()
            {
                base.CreateChildControls();
                this.ListContainer.RepeaterControl.ItemDataBound += new RepeaterItemEventHandler(this.RepeaterControl_ItemDataBound);
            }
     
            void RepeaterControl_ItemDataBound(object sender, RepeaterItemEventArgs e)
            {
                if (e.Item.ItemType == ListItemType.Header || e.Item.ItemType == ListItemType.Item)
                {
                     
                    var authorwrap = e.Item.FindControl("AuthorWrap") as TableHeaderRow;
                    authorwrap.Visible = false;
                    // hide the <th> after you find it by ID.
                    // id="AuthorWrap"
     
                }
            }
        }

    Regards
    Snehal
  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    27 May 2011
    Link to this post
    Hello,


    You can get the maser and detail settings using

    var serializedList = this.MasterSettings;
    var serializedList1 = this.DetailSettings;

    Override CrateContentList and there Subscribe for the ItemDataBound

    protected override void CreateContentList()
        {
            base.CreateContentList();
            ListContainer.RepeaterControl.ItemDataBound += new RepeaterItemEventHandler(RepeaterControl_ItemDataBound);
        }

        void RepeaterControl_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Header || e.Item.ItemType == ListItemType.Item)
            {
                // hide the <th> after you find it by ID.
                // id="AuthorWrap"
            }
        }

    This will trigger ItemDataBound event properly.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
11 posts, 1 answered