API Questions on Kentico API.
Version 5.x > API > Set NodeOrder when creating new document View modes: 
User avatar
Member
Member
bohtsu - 7/19/2011 4:37:39 PM
   
Set NodeOrder when creating new document
Is there a way to set the NodeOrder when adding a new folder? SetValue() doesn't seem to work and tnChildNode.NodeOrder is read only.

Here's the snippet of code:


foreach (DataRowView drvMonthRow in dvMonths)
{
string sMonth = Convert.ToString(drvMonthRow["MonthName"]);
CMS.TreeEngine.TreeNode tnMonthNode = new CMS.TreeEngine.TreeNode("CMS.Folder", provider);

// set document properties
tnMonthNode.NodeName = sMonth;
tnMonthNode.NodeAlias = sMonth;
tnMonthNode.SetValue("DocumentName", sMonth);
tnMonthNode.SetValue("DocumentCulture", "en-us");
tnMonthNode.SetValue("NodeOrder", drvMonthRow[2]);

// create New document
tnMonthNode.Insert(tnNewFolder.NodeID);
}

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 7/20/2011 5:03:58 AM
   
RE:Set NodeOrder when creating new document
Hello,


Yes, the property is read-only. You can use these methods to change NodeOrder:

CMS.TreeEngine.TreeProvider.MoveNodeDown(int nodeId)
CMS.TreeEngine.TreeProvider.MoveNodeUp(int nodeId)

Please see the API Reference for more details.


Best regards,
Helena Grulichova