It's a little bit more complicated than ExecuteAction but it's do-able.
Here's a code snipet for Managed Code. It should be trivial to change it to
Javascript.
thisXDocument.View.ExecuteAction("xCollection::insert", "group2_3");
IXMLDOMNode parent =
thisXDocument.DOM.selectSingleNode("/my:myFields/my:group1");
IXMLDOMNode node = parent.childNodes[parent.childNodes.length - 1];
parent.insertBefore(node, parent.childNodes[0]);

Signature
Andrew J. Ma
Software Test Engineer
Microsoft Office InfoPath
http://blogs.msdn.com/ajma
---------------------------------------
This posting is provided "As Is" with no warranties, and confers no rights.
Use of any included script sample are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.
Please do not send email directly to this alias. This alias if for
newsgroup purposes only.
>I have a button on my form that calls the following command:
> XDocument.View.ExecuteAction("xCollection::insert", "group2_1");
>
> This works great and adds a new item at the bottom of the form. I want the
> button to add a new itemn at the very top every time. Is there any way to
> programatically move the new item to the top of the form?
Eric Langland [MS] - 02 Sep 2004 21:33 GMT
Andrew,
Thanks for the help. I think I'm close but for some reason my code is not
moving the item to the top of the list. It successfully adds a new item and
then selects it but it's not moving it to the top. Any ideas?
Thanks, much appreciated.
XDocument.View.ExecuteAction("xCollection::insert", "group2_1");
var parent =
XDocument.DOM.selectSingleNode("/my:myFields/my:group1/my:group2")
XDocument.View.SelectNodes(parent)
var node = parent.childNodes[parent.childNodes.length - 1];
parent.insertBefore(node, parent.childNodes[0]);
> It's a little bit more complicated than ExecuteAction but it's do-able.
>
[quoted text clipped - 16 lines]
> > button to add a new itemn at the very top every time. Is there any way to
> > programatically move the new item to the top of the form?