Allowing reordering of custom module items - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Allowing reordering of custom module items

  • Allowing reordering of custom module items
  • I have created a custom module and would like to enable the reordering of the module content items through the backend grid view (in the same manner that List Items can be modified).

    From what I can tell, I need to create an ordinal field in the database table for my content item.  Then I need to add a drag & drop reordering column to my MasterGridViewElement.

    How do I do this?
  • Check out App_Data/Sitefinity/Configurations/toolboxes.config

    I think you should be able to reorder them in the file and the changes will appear in the frontend.
  • Thank you for the reply Mark.

    I am not trying to reorder the modules, but rather the content items that my custom module manages.
  • Hi Antoine,

    I presume you want to reorder the items( text fields, image upload, details, categories and tags). This is done in the Definitions file of your module. I will use Products module(available with Sitefinity SDK) as an example.
    In ProductsDefinitions.cs you will notice you have #region Main section,#region Categories and Tags and etc. Under the definition of the section elements are added from top to bottom. This is how they appear in the backend of the module.
    var titleField = new TextFieldDefinitionElement(mainSection.Fields) // Title of Product Item
    var dropDownTaxonomyField = new TaxonFieldDefinitionElement(mainSection.Fields) // the color selector
    var contentField = new HtmlFieldElement(mainSection.Fields) // the body where you enter product information

    To reorder the items in any way you like you can copy paste them to change positioning or create new section following the example of how the existing sections are defined.


    Kind regards,
    Stanislav Velikov
    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
  • 287799_sorting-grabbers.png
    Actually, that is not what I meant.  I will attempt to be more clear.

    I have created a Contacts modules.  I would like to control the sort order of the contacts on the front end using the drag and drop functionality that is available in the Pages manager as well as the List module.

    I have attached a screenshot of the sorting mechanism in the List Items module as an example of what I want to implement in my module.

    Thank you for your response.
  • There is not response to this post?
    This is a feature that I think a lot of developer would like to do instead of adding a manual order for the final user.


  • Hi Francisco,

    Sorting can be changed in the frontend widget of the module. Edit the widget advanced properties Home > ControlDefinition > Views > ProductsFrontendList and change SortExpression. Or in the code of the module in MasterListView
    CultureInfo uiCulture = null;
                   if (AppSettings.CurrentSettings.Multilingual)
                   
                       uiCulture = System.Globalization.CultureInfo.CurrentUICulture;
                   
                   //the filter is adpated to the implementation of ILifecycleDataItemGeneric, so the culture is taken in advance when filtering published items.
                   this.FilterExpression = ContentHelper.AdaptMultilingualFilterExpression(this.FilterExpression);
                   var filterExpression = DefinitionsHelper.GetFilterExpression(this.FilterExpression, this.AdditionalFilter);
                   query = Telerik.Sitefinity.Data.DataProviderBase.SetExpressions(
                       query,
                       filterExpression,
                       "Title ASC",
                       uiCulture,
                       itemsToSkip,
                       masterDefinition.ItemsPerPage,
                       ref totalCount);

    Concerning the drag and drop functionality, there is no sample available. In Sitefinity this is achieved on the client with javascript events of RadGrid used to list all module items.

    Greetings,
    Stanislav Velikov
    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
  • I would also like to express my interest for a Sitefinity example that implements ordering the Sitefinity way.

    Until this exists, I have decided to create the Ordinal field as a Float on my content items.

    [DataMember]
    public float Ordinal get; set;

    I then expose the ordinal for editing on the content editor form.

    var ordinalField = new TextFieldDefinitionElement(mainSection.Fields)
        ID = "ordinalFieldControl",               
        DataFieldName = "Ordinal",
        DisplayMode = displayMode,
        Title = "Ordinal",
        CssClass = "sfTitleField",
        ResourceClassId = typeof(PromotionsResources).Name,
        WrapperTag = HtmlTextWriterTag.Li
    ;
    ordinalField.ValidatorConfig = new ValidatorDefinitionElement(ordinalField)
        Required = true,
        MessageCssClass = "sfError",
        RequiredViolationMessage = Res.Get<PromotionsResources>().OrdinalCannotBeEmpty
    ;
    mainSection.Fields.Add(ordinalField);

    While this is not the desired experience, I am hoping when a sample that implements custom ordering becomes available it will be easy to implement since the backend is already available.

    Here is another post about ordering of custom content items that is a little more helpful but still not a usable example of how to implement.

    http://www.sitefinity.com/devnet/forums/sitefinity-4-x/general-discussions/how-to-implement-moving-of-items-up-and-down.aspx 

    JASON CHESTER
    Technology Director
    rosetta.com



  • I would still love to see this feature available to the custom modules.

    It is present in the pages module and we need a simplified version of it to prioritise records. eg: in the case of a contact list, drag and drop people so the most important person is at the top of the list. At present we just use a numeric field that is manually edited to achieve the desired output on the front-end but for back-end administration it is far from desirable to drag and drop contacts in order.
  • If we can drag and drop order for the pages why can we not turn it on elsewhere? 
  • Hello,

    The ordering on page level is available since there is a property called Ordinal for the PageNodes. This property is used to track a page's location in the tree view and it is recalculated each time a page is moved from its location. Additionally as page list actually uses Tree view to display the pages, the dynamic modules use Grid for which there is no drag & drop ordering functionality. We have a PITS issue opened for this feature request so you can follow its progress and vote to increase its popularity. 

    You can set a sorting expression for the view from Administration->Settings->Advanced->DynamicModules->Controls->your module->Views->YourModuleBackendList using the Sort Expression field.

    Regards,
    Pavel Benov
    Telerik
    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
  • Where is the PITS issue? Same problem in SF that requested feature in 2011 is still not there in 2014

     

  • Hello,

    You can find this feature request available on the following url:

    http://feedback.telerik.com/Project/153/Feedback/Details/100801-module-builder-drag-drop-ordering-on-backend-list

    Please cast your vote up to increase its popularity and subscribe for automatic notifications.

    Regards,
    Pavel Benov
    Telerik
     
    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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  • Edit: Apologies, I forgot to switch to the List settings view and select "Sort as set manually"

     

    @PavelBenov

    Was this feature ever implemented? 

    And to be clear: Are we talking about creating the custom module then on a page you drag and drop the generated widget onto the page and on then you click Edit > Content > Select _content type_, then you select a bunch of your custom items in the 'Select _content type_' dialog and finally in the 'Selected' tab of the same dialog you can drag items into the order that you desire? 

    If it is, then the functionality seems to be there, but Sitefinity doesn't seem to adhere to the order you specify...  
    The designer/backend editing view seems to keep the order you specified between page edits, but the front end view doesn't.