示例#1
0
        public void MoveToFirst(SPNavigationNodeCollectionInstance collection)
        {
            if (collection == null)
            {
                throw new JavaScriptException(this.Engine, "Error", "SPNavigationNodeCollection must be specified.");
            }

            m_navigationNode.MoveToFirst(collection.SPNavigationNodeCollection);
        }
示例#2
0
        /// <summary>
        /// reads a set of integers
        /// that represents a recorded node movement and
        /// perform the node re-ordering
        /// </summary>
        /// <param name="movementInfo"></param>
        private void MoveNode(string[] movementInfo)
        {
            int parentNodeID = Convert.ToInt32(movementInfo[0]);
            int oldIndex     = Convert.ToInt32(movementInfo[1]);
            //if (_appId != -1)
            //{
            //    // translate displayed index into real index in Web.Navigation
            //    oldIndex = AppSettingsHelper.GetRealIndex(parentNodeID, oldIndex, _appId, _nodeType);
            //}
            int newIndex = Convert.ToInt32(movementInfo[2]);
            //if (_appId != -1)
            //{
            //    // translate displayed index into real index in Web.Navigation
            //    newIndex = AppSettingsHelper.GetRealIndex(parentNodeID, newIndex, _appId, "topnav");
            //}

            SPNavigationNode           parentNode            = _web.Navigation.GetNodeById(parentNodeID);
            SPNavigationNodeCollection contextNodeCollection = parentNode.Children;
            SPNavigationNode           node = contextNodeCollection[oldIndex];

            int currentlastIndex = contextNodeCollection.Count - 1;

            if (newIndex != oldIndex)
            {
                if (newIndex == 0)
                {
                    node.MoveToFirst(contextNodeCollection);
                }
                else if (newIndex == currentlastIndex)
                {
                    node.MoveToLast(contextNodeCollection);
                }
                else
                {
                    if (newIndex < oldIndex)
                    {
                        node.Move(contextNodeCollection, contextNodeCollection[newIndex - 1]);
                    }
                    else
                    {
                        node.Move(contextNodeCollection, contextNodeCollection[newIndex]);
                    }
                }
            }

            // note:
            // when performing SPNavigationNode.(Move/MoveToFirst/MoveToLast)
            // SPNavigationNode.Update() is not necessary according to MSDN documents
        }
示例#3
0
        /// <summary>
        /// reads a set of integers
        /// that represents a recorded node movement and
        /// perform the node re-ordering
        /// </summary>
        /// <param name="movementInfo"></param>
        private void MoveNode(string[] movementInfo)
        {
            int parentNodeID = Convert.ToInt32(movementInfo[0]);
            int oldIndex     = Convert.ToInt32(movementInfo[1]);
            int newIndex     = Convert.ToInt32(movementInfo[2]);

            _eWeb.AllowUnsafeUpdates = true;

            SPNavigationNode           eParentNode            = _eWeb.Navigation.GetNodeById(parentNodeID);
            SPNavigationNodeCollection eContextNodeCollection = eParentNode.Children;
            SPNavigationNode           eNode = eContextNodeCollection[oldIndex];

            int currentlastIndex = eContextNodeCollection.Count - 1;

            if (newIndex != oldIndex)
            {
                if (newIndex == 0)
                {
                    eNode.MoveToFirst(eContextNodeCollection);
                }
                else if (newIndex == currentlastIndex)
                {
                    eNode.MoveToLast(eContextNodeCollection);
                }
                else
                {
                    if (newIndex < oldIndex)
                    {
                        eNode.Move(eContextNodeCollection, eContextNodeCollection[newIndex - 1]);
                    }
                    else
                    {
                        eNode.Move(eContextNodeCollection, eContextNodeCollection[newIndex]);
                    }
                }
            }

            // note:
            // when performing SPNavigationNode.(Move/MoveToFirst/MoveToLast)
            // SPNavigationNode.Update() is not necessary according to MSDN documents
        }