How To: Format the display for a view in details mode |
Article Type | How To |
Title | Format the display for a view in details mode |
| <i>I want to display a custom format for a view when it's displayed in details mode,
but I want to use the default formatting for the grid, insert, and update modes.</i>
<p><b>Solution</b></p>
<p>To format a view so that it displays a custom format in details mode, but
uses the default formatting for the grid, insert, and update modes, you can use
an HTML block to specify formatting for details mode only. First, set the <i>displaymodes</i>
attribute of the field box to "grid,update,insert", so that the field
box will not be displayed in details mode. </p>
<p>Next, create an HTML block within the data region, and set its <i>displaymodes</i>
attribute to "details." You can specify custom formatting for details
mode within the HTML block. To retrieve the data for each field within the HTML
block, use Dataweb substitution syntax and return the value of each named field
property on the <b>record</b> object.</p>
Here is the source XML for a sample view:
<pre>
<ws:dataregion defaultmode="details"
actionbarposition="bottom"
jumpbarposition="top">
<ws:datasource src="ExampleData" />
<ws:fieldbox displaymodes="grid,update,insert">
<ws:action type="showupdatepage" displaytype="image"
displaymodes="grid,details" displayrole="author" />
<ws:field name="FirstName">
<ws:caption>First Name</ws:caption>
</ws:field>
<ws:field name="LastName">
<ws:caption>Last Name</ws:caption>
</ws:field>
<!--other fields included here...-->
</ws:fieldbox>
<ws:htmlblock displaymodes="details">
#response.encodeHTML
( record.FirstName + " " + record.LastName )#:<br />
#response.encodeHTML( record.Company )# :<br />
#response.encodeHTML( record.Phone )# :<br />
#response.encodeHTML( record.Email )# :<br />
</ws:htmlblock>
<ws:actionbar> ... </ws:actionbar>
<ws:caption>Contacts</ws:caption>
</ws:dataregion>
</pre>
Note that, within the <b>ws:fieldbox</b> tag, we use the <b>ws:field</b> tag to
retrieve the value of a field:
<ul>
<li><ws:field name="<i>columnname</i>"> </ws:field></li>
</ul>
Within the <b>ws:htmlblock</b> tag, we use Dataweb substitution syntax to refer
to the <b>record</b> object:
<ul>
<li>#response.encodeHTML( record.<i>columnname</i> )#</li>
</ul>
To ensure our field data is properly escaped, we use the <b>encodeHTML</b> method of the <b>response</b> object.<br>
<br>
Note also that to refer to a field as a property of the <b>record</b> object,
that field must be included in a <b>ws:field</b> tag inside the data region. If
there is a field that you want to display using Dataweb substitution syntax but
not in the field box, set the <i>displaymodes</i> attribute to <i>"never"</i>
for that field's <b>ws:field</b> tag.<br>
<br> |
Last Reviewed | February 20, 2015 14:07:57 |
|