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

Forums / General Discussions / Delete icon on history tab

Delete icon on history tab

6 posts, 0 answered
  1. Rabindra
    Rabindra avatar
    106 posts
    Registered:
    17 May 2009
    19 Apr 2010
    Link to this post
    Hi,
    Is it possible to place a delete button or icon next to View / Roll Back for each versions in Pages and modules ?
    I do have sql query that deletes every history but I didn't want to use that.

    thanks
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    19 Apr 2010
    Link to this post
    Hello Rabindra,

    You could but a LinkButton in the GridView that is declared in Sitefinity\Admin\ControlTemplates\Pages\PageHistory.ascx

    <div class="workArea">
    <cc1:MessageControl runat="server" ID="message">
    <ItemTemplate>
        <asp:Label runat="server" ID="messageText"></asp:Label>
    </ItemTemplate>
    </cc1:MessageControl>
    <asp:MultiView id="PageHistoryMultiView" ActiveViewIndex="0" runat="server">
         <asp:View id="History" runat="server">  
            <h2 class="gridTitle"><asp:Literal runat="server" Text="<%$Resources:Versions %>"></asp:Literal></h2>           
            <asp:GridView ID="GridView1" AllowPaging="true" PageSize="20" AutoGenerateColumns="false" GridLines="none" CssClass="listItems history" runat="server">
                <Columns>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:HyperLink ID="PreviewLink" runat="server"><asp:Literal runat="server" Text="<%$Resources:View %>"></asp:Literal></asp:HyperLink
                            <asp:LinkButton ID="RollbackButton" runat="server"><asp:Literal runat="server" Text="<%$Resources:RollBack %>"></asp:Literal></asp:LinkButton>
                            <asp:LinkButton ID="RestoreButton" runat="server" Visible="true"><asp:Literal ID="Literal1" runat="server" Text="Restore"></asp:Literal></asp:LinkButton>
                             
                        </ItemTemplate>
                        <ItemStyle CssClass="gridActions" />
                    </asp:TemplateField>
                    <asp:BoundField DataField="Version" HeaderText="<%$Resources:Version %>"><ItemStyle CssClass="gridContentTitle" /></asp:BoundField>
                    <asp:BoundField DataField="Stamp" HeaderText="<%$Resources:Date %>" HeaderStyle-CssClass="GridHeader_SiteFinity" DataFormatString="<%$Resources:VersionDateFormat %>" HtmlEncode="false" />
                    <asp:BoundField DataField="Modifier" HeaderText="<%$Resources:Author %>" HeaderStyle-CssClass="GridHeader_SiteFinity" />
                    <asp:BoundField DataField="Theme" HeaderText="<%$Resources:Theme %>"><ItemStyle /></asp:BoundField>
                  <asp:TemplateField AccessibleHeaderText="DoSomething">
                  <ItemTemplate>
                   <asp:LinkButton  Text='<%# Eval("ID") %>' CommandArgument='<%# Eval("Version") %>' CommandName="DoSomething" ID="LinkButton1" runat="server" Visible="true"><asp:Literal ID="Literal2" runat="server" Text="DoSomething"></asp:Literal></asp:LinkButton>
                  </ItemTemplate>
                  </asp:TemplateField>
                
                </Columns>
            </asp:GridView>
         </asp:View>
         <asp:View id="NoHistory" runat="Server">
            <div class="center">
                <asp:Literal runat="server" Text="<%$Resources:NoHistoryMessage %>"></asp:Literal>
            </div>
         </asp:View>
     </asp:MultiView>
    </div>


    Regards,
    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. Rabindra
    Rabindra avatar
    106 posts
    Registered:
    17 May 2009
    19 Apr 2010
    Link to this post
    hi Ivan,
    Do I need to create code behind for pagehistory.ascx?

    I see<%# Eval("ID") %> and CommandArgument='<%# Eval("Version") %> but Which table (s) do I need to delete from?

    When I said I had sql query, I was referring to this page.
    http://www.sitefinity.com/support/kb/sitefinity-3-x/how-to-reduce-the-project-database-size.aspx
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    19 Apr 2010
    Link to this post
    Hello Rabindra,

    Using a link button you could access the page by ID. Then you can use DeleteItem(IVersionItem item) method of the VersionManager to delete a certain version or construct your own SQL query that removes the data from sf_VersionItem. Generally I suggest that you should use the API.

    Sincerely yours,
    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.
  5. Rabindra
    Rabindra avatar
    106 posts
    Registered:
    17 May 2009
    20 Apr 2010
    Link to this post
    Hi Ivan,
    I tried
    VersionManage.DeleteItem(ID)
    VersionManage.DeleteItem(ID, null, Version)

    and both of them do not work. I can still see version on History tab.

    To test, I used this select statement against sf_VersionItem  table and got no results.
    select * from sf_VersionItem  where ID='620ea974-9482-4d5f-96bb-de5e727c89c1'

    But I can see versions on History tab.
    what is wrong here.

    Also on this link http://www.sitefinity.com/support/kb/sitefinity-3-x/how-to-reduce-the-project-database-size.aspx
    nowhere does it mention to used delete statement against sf_VersionItem table.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    20 Apr 2010
    Link to this post
    Hi Rabindra,

    Here is how to delete all versions of a given page

    if (e.CommandName == "remove")
           {
               var cm = new Telerik.Cms.CmsManager();
               var p = cm.GetPage(HERE GET THE PAGE BY ID));
               System.Collections.Generic.IList<Telerik.Cms.IStagedPage> history = p.GetAllHistory();
               if (history.Count > 0)
               {
                   Nolics.ORMapper.Base.Transaction tran = new Nolics.ORMapper.Base.Transaction();
                   foreach (Telerik.Cms.Data.StagedPage item in history)
                   {
                       tran.Join(item);
                       item.Delete();
                   }
                   tran.Commit();
               }
           }

    It is not possible to delete only certain version

    Regards,
    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.
Register for webinar
6 posts, 0 answered