Skip to content
Hub Nexus

No author yetClaim it

Version 1Updated 1 min read

Support

Motivation

It is very often useful to highlight the selected row. This is done with a xform-repeat-index pseudo element in the style sheet.

CSS

By adding the following to your CSS the selected row will be highlighted in blue:

.xforms-repeat-index {
background-color: blue;
}

Screen Image

This example highlights the background of the selected row.

This example was run using the FormFaces system.

Program Code

<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events">
<head>
<title>XForms Delete Example</title>

<script type="text/javascript" src="formfaces.js"></script>
<style type="text/css">

  • {
    font-family: Ariel, Helvetica, sans-serif;
    }

label, legend {
font-weight: bold;
}

.header {
color: white;
background-color: gray;
font-weight: bold;
padding: 2px;
}

.header {
width: 370px;
}

.leftColumn, .rightColumn {
display: inline;
}

.leftColumn {
margin-left: 10px;
}

.rightColumn {
position: absolute;
left: 0;
margin-left: 150px;
}

fieldset {
width: 380px;
}

.xforms-repeat-index {
background-color: blue;
}

</style>
<xf:model>
<xf:instance>
<PhoneList xmlns="">
<Person>
<Name>Peggy</Name>
<Phone>123</Phone>
</Person>
<Person>
<Name>Dan</Name>
<Phone>456</Phone>
</Person>
<Person>
<Name>John</Name>
<Phone>789</Phone>
</Person>
<Person>
<Name>Sue</Name>
<Phone>234</Phone>
</Person>
<NewPerson>
<Name />
<Phone />
</NewPerson>
<SelectedRow />
</PhoneList>
</xf:instance>
</xf:model>
</head>
<body>
<xf:group nodeset="/PhoneList">
<fieldset>
<legend>Company Phone List</legend>
<div class="header">
<div class="leftColumn">Name</div>
<div class="rightColumn">Phone</div>
</div>
<xf:repeat id="list" nodeset="Person">
<xf:input ref="Name" class="leftColumn"><xf:label></xf:label></xf:input>
<xf:input ref="Phone" class="rightColumn"><xf:label></xf:label></xf:input>
</xf:repeat>
</fieldset>
<fieldset>
<legend>Add New Person</legend>
<xf:input ref="NewPerson/Name">
<xf:label>Name:</xf:label>
</xf:input>
<br />
<xf:input ref="NewPerson/Phone">
<xf:label>Phone:</xf:label>
</xf:input>
<xf:trigger>
<xf:label>Insert After Selected Row</xf:label>
<xf:action ev:event="DOMActivate">
<xf:insert nodeset="Person" at="index('list')" position="after" />
<xf:setvalue ref="Person[index('list')]/Name" value="/PhoneList/NewPerson/Name" />
<xf:setvalue ref="Person[index('list')]/Phone" value="/PhoneList/NewPerson/Phone" />
<xf:setvalue ref="SelectedRow" value="index('list')" />
</xf:action>
</xf:trigger>
</fieldset>
<xf:trigger>
<xf:label>Delete Selected Row</xf:label>
<xf:action ev:event="DOMActivate">
<xf:delete nodeset="Person" at="index('list')" />
</xf:action>
</xf:trigger>
<xf:output ref="SelectedRow">
<xf:label>Selected Row= </xf:label>
</xf:output>
</xf:group>
</body>
</html>

Discussion

Note that this only works when you select a row an click your cursor on the input field. The result is that the value of the index for the selected list will change. This can be used by the functions that add or delete a selected row.

Known bugs

This appears to not be functional under the FireFox extension as of 0.6.

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
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
CC BY-SA 4.0
This program demonstrates how XForms can validate a data set based on the facets within and XML Schema. ## Warnings Note: This program does not run under the FireFox 0.6 extension. The X-Smiles browser was used to demonstrate this program. ## Screen Image This screen image was taken from the [X-Smil
CC BY-SA 4.0
XForms, SVG