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

Forums / Developing with Sitefinity / Can the "Status" column in the "Generic Content > Content Items" view under Modules be made sortable?

Can the "Status" column in the "Generic Content > Content Items" view under Modules be made sortable?

7 posts, 0 answered
  1. Mike Boyle
    Mike Boyle avatar
    22 posts
    Registered:
    17 Dec 2009
    13 Jan 2010
    Link to this post
    I was wondering if it is possible to make the "Status" column in the "Generic Content > Content Items" view under Modules be made sortable. We would like to be able to sort this view to see items that are pending approval at the top of the list.

    Thanks for your help.
  2. Mike Boyle
    Mike Boyle avatar
    22 posts
    Registered:
    17 Dec 2009
    13 Jan 2010
    Link to this post
    I see in this post: http://www.sitefinity.com/support/forums/sitefinity-3-x/set-up-installation/workflow.aspx that the column should be sortable (shown in the image provided by Georgi). That does not appear to be the case for the generic content view. Is there a setting for this?

    Thanks again for your help.
  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    13 Jan 2010
    Link to this post
    Hi Mike Boyle,

    It is not possible to filter or sort by "Status"

    There are two options

    1. Crate a new very simple view that is bound to the desired content items.
    2. Create  new metakey that you can use to persists the current status of the content item and then perform the Sorting in the ContentItemsList view. You have to map the external template for ContentItemsList and add the new metakey there

    sample modification of the template

    <telerik:ClientTemplatesHolder ID="GridTemplates" runat="server">
            <telerik:ClientTemplate ID="ClientTemplate1" Name="Edit" runat="server">
                <a href="<%= ((Telerik.Cms.Engine.WebControls.Admin.ContentItemsList<Telerik.Cms.Engine.WebControls.Admin.ContentItemsView>)Parent.Parent).ItemEditUrl %>"><asp:Literal ID="Literal1" Text="<%$ Resources:Edit %>" runat="server" /></a>
            </telerik:ClientTemplate>
            <telerik:ClientTemplate ID="ClientTemplate2" Name="Delete" runat="server">
                <a href="javascript:if(confirm('<%= GetLocalResourceObject("AreYouSure_Delete") %>')) DeleteContent('{#ID#}')"><asp:Literal ID="Literal2" Text="<%$ Resources:Delete %>" runat="server" /></a>
            </telerik:ClientTemplate>
            <telerik:ClientTemplate ID="ClientTemplate3" Name="View" runat="server">
                <a href="<%= ((Telerik.Cms.Engine.WebControls.Admin.ContentItemsList<Telerik.Cms.Engine.WebControls.Admin.ContentItemsView>)Parent.Parent).ItemViewUrl %>">{#MetaFields.Name#}</a>
            </telerik:ClientTemplate>
            <telerik:ClientTemplate ID="ClientTemplate4" Name="Author" runat="server">
                {#MetaFields.Author#}
            </telerik:ClientTemplate>
            <telerik:ClientTemplate ID="ClientTemplate5" Name="Description" runat="server">
                {#MetaFields.Description#}
            </telerik:ClientTemplate>
            <telerik:ClientTemplate ID="ClientTemplate7" Name="ContentStatus" runat="server">
                {#MetaFields.ContentStatus#}
            </telerik:ClientTemplate>
            <telerik:ClientTemplate ID="ClientTemplate6" Name="Status" runat="server">
                {#Status#}
            </telerik:ClientTemplate>
        </telerik:ClientTemplatesHolder>
        <div id="gridPlaceholder">
        <telerik:RadGrid ID="ItemsGrid" runat="server" AutoGenerateColumns="false" AllowSorting="true" AllowPaging="true" PageSize="50" EnableViewState="false" Skin="SitefinityItems" EnableEmbeddedSkins="false"
         AllowMultiRowSelection="true">
            <MasterTableView AllowMultiColumnSorting="false" CssClass="listItems listItemsBindOnClient" Width="98%" >
                <Columns>
                    <telerik:GridTemplateColumn ItemStyle-CssClass="gridActions edit" UniqueName="Edit">
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn
                        UniqueName="Delete" ItemStyle-CssClass="gridActions delete">
                    </telerik:GridTemplateColumn>
                    <telerik:GridClientSelectColumn UniqueName="CheckBoxColumn" HeaderStyle-CssClass="check" ItemStyle-CssClass="check">
                    </telerik:GridClientSelectColumn>
                    <telerik:GridTemplateColumn
                        UniqueName="View" 
                        SortExpression="Name"
                        ItemStyle-CssClass="gridContentTitle"
                        HeaderText="<%$ Resources:Name %>">
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn
                        UniqueName="Author" 
                        SortExpression="Author"
                        HeaderText="<%$ Resources:Author %>">
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn
                        UniqueName="Description" 
                        HeaderText="<%$ Resources:Description %>">
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn
                        UniqueName="ContentStatus" 
                        HeaderText="<%$ Resources:ContentStatus %>">
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn
                        SortExpression="Status"
                        UniqueName="Status"
                        HeaderText="<%$ Resources:Status %>">
                    </telerik:GridTemplateColumn>
                </Columns>
            </MasterTableView>
            <PagerStyle Mode="NumericPages" />
            <ClientSettings>
                <ClientEvents OnCommand="RadGrid_Command" OnRowDataBound="RadGrid_RowDataBound" OnRowSelected="RadGrid_RowSelected" OnRowDeselected="RadGrid_RowDeselected" />
                <Selecting AllowRowSelect="true" />
            </ClientSettings>
        </telerik:RadGrid>
        </div>
        <asp:HiddenField ID="cultureInfoField" runat="server" />
         <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
    <!--
    var dataProviderName = "<%= ((Telerik.Cms.Engine.WebControls.Admin.ContentItemsList<Telerik.Cms.Engine.WebControls.Admin.ContentItemsView>)Parent.Parent).ProviderName %>";
    var gridTemplates = ClientTemplates.GetSet("<%= GridTemplates.ClientID %>");
    var allowDelete = "<%= ((Telerik.Cms.Engine.WebControls.Admin.ContentItemsList<Telerik.Cms.Engine.WebControls.Admin.ContentItemsView>)Parent.Parent).AllowDelete %>";
    var allowModify = "<%= ((Telerik.Cms.Engine.WebControls.Admin.ContentItemsList<Telerik.Cms.Engine.WebControls.Admin.ContentItemsView>)Parent.Parent).AllowModify %>";
    var groupOpsDivVisible = false;
     
    function loadData() {
        var tableView = $find('<%= ItemsGrid.ClientID %>').get_masterTableView();
        var currentPageIndex = tableView.get_currentPageIndex();
        var pageSize = tableView.get_pageSize();
        var filterExpressionField = document.getElementById('<%= FilterExpressionField.ClientID %>');
        DataBindGrid(currentPageIndex, pageSize, "", filterExpressionField.value);
    }
    Sys.Application.add_load(loadData);
    function DataBindGrid(currentPageIndex, pageSize, sortExpressionsAsSQL, filterExpressionsAsSQL) {
        var requiredMetaFields = ['Name', 'Author', 'Description', 'ContentStatus'];
        var cultureInfoField = document.getElementById('<%= cultureInfoField.ClientID %>');
        Telerik.Cms.Engine.Services.ContentService.GetContentItems(currentPageIndex * pageSize, pageSize,
        sortExpressionsAsSQL, filterExpressionsAsSQL, requiredMetaFields, cultureInfoField.value, dataProviderName, updateGrid, OnFailed);
    }


    Kind regards,
    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.
  4. Mike Boyle
    Mike Boyle avatar
    22 posts
    Registered:
    17 Dec 2009
    13 Jan 2010
    Link to this post
    Thank you for the detailed information. I may end up going this route.

    Before I do implement this, another solution that might work would be to add "Status" to the search dropdown in the "Generic Content > Content Items" view under Module. I see what appears to be a solution for this here: "http://www.sitefinity.com/support/forums/sitefinity-3-x/developing-with-sitefinity/implement-search-items-by-in-custom-modules.aspx".

    I don't quite understand this portion:

    "For example, if you search Generic Content items by Name for "test", the filter expression would look like Param=Name+LIKE+"test". You would have to include this in the querystring using the ParameterKey property of ViewModeControl, and then filter the content you bind to, according to this expression. Just call GetContent method of your manager with the overload having a filterExpression parameter. That's all there is to it.

    If your view is inheriting from ContentItemView, then it would be even easier, as the base provides methods and properties to do this automatically, you would just have to parse the query. Take a look at FilterExpression and NavigateFilterListCommand in ContentItemList."

    I did add the "Status" item to the web.config as mentioned and it does show up in the dropdown. I also see it in the Querystring parameters (page available in uploaded image):
    "http://localhost:1388/Company/Sitefinity/Admin/Modules.aspx?route=GenericControlPanel.ContentItemsView.ContentItemsList`1&Param=Status+LIKE+%22Declined%22&ParentId=00000000-0000-0000-0000-000000000000"

    I'm not sure where and how to parse the query. Does this solution require a custom view as well?

    Thanks again.
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    13 Jan 2010
    Link to this post
    Hello Mike Boyle,

    You have to modify ContentItemPreview template and programmatically save the workflow status as "Status"  metakey. You have to work with staged content objects. We discussed similar implementation for news yesterday and earlier today.

    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.
  6. Mike Boyle
    Mike Boyle avatar
    22 posts
    Registered:
    17 Dec 2009
    13 Jan 2010
    Link to this post
    Hi Ivan.

    I am implementing the ContentItemsList view template as you suggested. I don't seem to be able to persist the value for ContentStatus back to SiteFinity. I have the following lines in my code behind:

     content.SetMetaData("ContentStatus", "ForApproval");  
     contentManager.SavedStagedContent(content, ContentStatus.Published);  
     

    In my view the ContentStatus keeps showing "undefined" even after updating the the status through workflow. I've attached another image for your info.

    Any ideas?

    Thanks.
  7. Mike Boyle
    Mike Boyle avatar
    22 posts
    Registered:
    17 Dec 2009
    13 Jan 2010
    Link to this post
    I actually did get this to work. I was missing some meta definitions for the new field. Now I'll just need to see if there's a  quick way to bulk update this new metakey for all the existing generic content items.

    Thanks for you help.
Register for webinar
7 posts, 0 answered