Custom Module Need Custom Action

Posted by Community Admin on 04-Aug-2018 00:41

Custom Module Need Custom Action

All Replies

Posted by Community Admin on 01-Feb-2012 00:00

I have a module where my client would like to see in the List View a way to resort the items as they'll be displayed to the end user (I have a data element in my model called DisplaySequence which will sort the list of items, I also have all of the underlying CRUD functionality already built up). I simply need a couple of action menu items on my list view that will call "Move Up"/"Move Down" / "Top"/"Bottom" (to move the items up or down, or to the top/bottom). When those buttons get hit I'd like to call the functions I've built in my data manager. How do I get the custom actions into my Definitions class? Will I need to create new javascript files to handle the actions (and if so can I be provided with a template on achieving that functionality?).

Posted by Community Admin on 02-Feb-2012 00:00

Hello John,

I would suggest you to check the following forum posts -

http://www.sitefinity.com/devnet/forums/sitefinity-4-x/developing-with-sitefinity/allowing-reordering-of-custom-module-items.aspx 

and

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

Greetings,
Lubomir Velkov
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

Posted by Community Admin on 03-Feb-2012 00:00

Hi Lubomir,

I reviewed both of the links you sent. They did not unfortunately, however, provide usable examples of the code, both posts were left incomplete. The one on reordering Stanislav Velikov left with a comment that there is no sample available concerning drag and drop functionality of content items (which I would really like to have). The second post on implementing the moving of items up and down was also incomplete, Radoslav Georgiev left it with a comment that we would still need to implement the server logic for changing the ordinal on the javascript databind. If I can get a working sample going I would be more than happy to post the results in the forum for others to use. :)

I have everything working up to that point. What I need for it to do is call the server back so I can implement the sorting logic. How do I get my js code to tie back to my service? (my service is called CareersModule.Web.Services.CareersBackendService, my content item (CareerItem) implements Content and IOrderedItem) 

<code>   
// handles the commands fired by a single item
    _itemMoveCommandHandler: function (sender, args)
        var productItemId = args._dataItem.Id;
        var currentList = this._masterView.get_currentItemsList();
        var binder = currentList.getBinder();

        switch (args.get_commandName())
            case 'moveUp':
                this._moveListItem(productItemId, binder, "up", args._dataItem, args._itemElement, args._itemIndex);
                break;
            case 'moveDown':
                this._moveListItem(productItemId, binder, "down", args._dataItem, args._itemElement, args._itemIndex);
                break;
            case 'moveTop':
                this._moveListItem(productItemId, binder, "top", args._dataItem, args._itemElement, args._itemIndex);
                break;
            case 'moveBottom':
                this._moveListItem(productItemId, binder, "bottom", args._dataItem, args._itemElement, args._itemIndex);
                break;
       
    ,

    _moveListItem: function (listItemId, binder, direction, dataItem, element, itemIndex)
        binder.DataBind();
   
</code>

It gets to the _moveListItem function fine (tested this in Firebug with some console.logs on the parameters), but DataBind() just refreshes the view and it does nothing. I also made an override for BatchMoveContentInternal and ReorderContent in the backend service but they're not being reached. I've tried using canMoveNode, canMoveContent, canModePage on the binder, nothing so far, is there a way to get a list of functions available from the binder, or would you be able to point me to the proper classes to look at to review the functionality?

Posted by Community Admin on 06-Feb-2012 00:00

Hello John,

Please review the following blog post -

http://www.sitefinity.com/blogs/lubomirvelkov/posts/12-01-22/extending_the_built-in_content_modules.aspx 

There is an example on how to call a web service through JavaScript and get the results from it, also how to refresh the master grid view.

I hope this helps.

All the best,
Lubomir Velkov
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

This thread is closed