Adding new repeating item with buttonclick

  • Thread starter Eric Langland [MSFT]
  • Start date
E

Eric Langland [MSFT]

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?
 
A

Andrew Ma [MSFT]

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]);


--
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.
 
E

Eric Langland [MS]

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]);


Andrew Ma said:
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]);


--
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.


Eric Langland said:
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top