Frederik
Frederik

Reputation: 249

How do I implement Move and Sort in an Umbraco custom section

I've created two custom sections which populate their trees from external (non-umbraco) tables. I've created implementations of ITaskReturnUrl to handle creation and deletion of nodes - this works fine. How do I make it work with the menu actions: Sort and Move?

I've added the appropriate actions to the menu of the nodes but when I click the action I get this error:

No node exists with id '1'

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ArgumentException: No node exists with id '1'

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[ArgumentException: No node exists with id '1']
   umbraco.cms.businesslogic.CMSNode.setupNode() +239
   umbraco.cms.businesslogic.CMSNode..ctor(Int32 Id) +36
   umbraco.dialogs.moveOrCopy.Page_Load(Object sender, EventArgs e) +1241
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
   System.Web.UI.Control.OnLoad(EventArgs e) +92
   umbraco.BasePages.BasePage.OnLoad(EventArgs e) +14
   System.Web.UI.Control.LoadRecursive() +54
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772

Upvotes: 2

Views: 727

Answers (1)

Frederik
Frederik

Reputation: 249

I decided to implement my own Sort-page with jquery-ui.

To reach the new page I created a new class implementing the IAction-interface (full version):

public string JsFunctionName
{
   get
   {
      return "OpenSortWindow();";
   }
}

public string JsSource
{
   get { return "function OpenSortWindow(){ var node = UmbClientMgr.mainTree().getActionNode();UmbClientMgr.openModalWindow('/Umbraco/Dialogs/RaceNodeSort.aspx?id='+ node.nodeId, 'Sort items', true, 350, 380); }"; }
}

The javascript opens a new dialog with my aspx-side that lets the user sort the elements. Please note that I use the UmbClientMgr.mainTree().getActionNode() to get the current node and read the nodeId-property which I insert into the URL of the page to passe this to the page.

This Action-class is then inserted into the context-menu through:

courseNode.Menu.Add(new RaceSortAction());

Upvotes: 1

Related Questions