Skip to content
Hub Nexus

No author yetClaim it

Version 1Updated 1 min read

Support

Motivation

In some instances you only want to add to the end of a list or delete from the end of a list. This program demonstrates how you can use the last() function to do this.

Screen Image

When you insert a new row, it will always be inserted at the end of the list. When you delete a row, it will also be removed from the end of the list.

Insert and delete from list

Sample Program

Repeat Demo

1
2
3

Value:

Insert new row

Delete last row

Discussion

Notice that the xf:insert uses the xf:action element to trigger on the DOM activate and the xf:delete uses the ev:event attribute to trigger the delete. This is because we need to include the xf:setvalue in the insert.

So, as a general rule, if you just need to use a single element in a trigger, you can use the ev:event attribute. But if you need to include several elements that all must be triggered you should wrap them in an an xf:action element.

Potential problem: when you have deleted all the nodes, the insert trigger does not work anymore. This is because the nodeset selection on the insert element is empty in that situation. If the nodeset selector is empty, the insert trigger has no meaning (see the first rule in 'rules for insert processing')

Where this page came from

This page was imported from Wikibooks. From “XForms” on Wikibooks, by its contributors, under CC BY-SA 4.0. Changed here: set as a page; navigation and edit links left out; each image under its own licence, credited in its caption.

Nobody has written it yet — it is the source material at a new address, which is why search engines are asked to skip it and why no one earns from it. It is up for grabs: take it on, and it is yours to rewrite and to earn from.

Get each new page of

XForms

Following means one email when a page is added, nothing when a page changes.

Following means one email when a page is added, nothing when a page changes.

Comments

Spinner Logo

Next in XForms

CC BY-SA 4.0
You can also add buttons to each row to move the selected row up or down. Note that after you add the row, you should move the insert cursor to the first field. This is done by using the setfocus element.
CC BY-SA 4.0
XForms, Highlight Selected Row
CC BY-SA 4.0
New items are always added to the end but you can delete an existing item just by selecting it and pressing the "Delete item" button.
CC BY-SA 4.0
As you select a single item, the details for that item will be shown on the lower part of the screen. ## Screen Image ![caption: note that when the mouse is in the second row the inspector is focused on the second item]( caption: note that when the mouse is in the second row the inspector is focused
CC BY-SA 4.0
Note that the argument is schema NOT src. src is used to read in the instance data. id="test" schema="data-types.xsd"> src="instance-data.xml"/> ## Screen Image Here is a screen image of a sample program. Note that input form for the date and boolean data types are automatically inferred from the XM
CC BY-SA 4.0
XForms, Validate with schema types