More in this section

Forums / Developing with Sitefinity / How can I add an extra field on NewsItemsList ?

How can I add an extra field on NewsItemsList ?

4 posts, 0 answered
  1. Bruno Michels
    Bruno Michels avatar
    125 posts
    16 Apr 2010
    27 Jul 2010
    Link to this post
    I want to add a new column that gets a MetaField value.

    Title   Author  Source  Publication Date    Expiration Date    MYFIELD    Status

    How can I do that?
  2. George
    George  avatar
    204 posts
    05 Sep 2006
    28 Jul 2010
    Link to this post
    Hi Bruno,

    To add a new metafield to the list :

    1- Add the metafield in the web.config file. Open the web.config and search for <metaFields> tag and add the following line

    <add key="News.MyField" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue="" />

    A-  Map the NewsItemsList to an external templates. To do so, download the external templates from the Downloads section in your account on Extract and locate the external template located in Sitefinity/Admin/ControlTemplates/News/NewsItemsList.ascx and copy it to the exact folder in your website project. Don't forget the relevant resource from App_LocalResources folder.

    B- Under App_Data create a folder called configuration, then add an xml field called Telerik.Sitefinity.Configuration.ControlsConfig.xml as follows:

    <?xml version="1.0" encoding="utf-8" ?>
        <viewSettings hostType="Telerik.News.WebControls.Admin.NewsItemsList" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/NewsItemsList.ascx" />

    3- Edit the NewsItemsList.ascx template to add your new meta field to the list.

    A- Search for telerik:ClientTemplatesHolder and add

    <telerik:ClientTemplate Name="MyField" runat="server">

    B- Search for telerik:RadGrid ID="ItemsGrid" and add a new column 

    <telerik:GridTemplateColumn UniqueName="MyField" SortExpression="MyField" HeaderText="<%$ Resources:MyField %>">

    C- Search for this function and update it

            function DataBindGrid(currentPageIndex, pageSize, sortExpressionsAsSQL, filterExpressionsAsSQL) {
                var requiredMetaFields = ['Title', 'Author', 'MyField', 'Source', 'Publication_Date', 'Expiration_Date'];
                var cultureInfoField = document.getElementById('<%= cultureInfoField.ClientID %>');
                Telerik.Cms.Engine.Services.ContentService.GetContentItems(currentPageIndex * pageSize, pageSize,
    sortExpressionsAsSQL, filterExpressionsAsSQL, requiredMetaFields, cultureInfoField.value, dataProviderName, updateGrid, OnFailed);

    and you're good to go. 

  3. Bruno Michels
    Bruno Michels avatar
    125 posts
    16 Apr 2010
    30 Jul 2010
    Link to this post
    What if MyField is not a metadata ? What if its a column of another table? How can I change the datasource?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    30 Jul 2010
    Link to this post
    Hello Bruno Michels,

    If it is a property of the object that is bound to the RadGrid you can use it. If not you need to rebind the grid or the control you are going to use in your scenario.

    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
Register for webinar
4 posts, 0 answered