How To: Incorporating HTML in different data region modes |
Article Type | How To |
Title | Incorporating HTML in different data region modes |
| <P>How-to: Incorporating HTML in different data region modes</P>
<P>This article explains how HTML is rendered in each of the various possible display modes of a data region.</P>
<P><B>Grid mode:</B></P>
<P>A data region in grid mode will render a <form> tag to the HTML only if both of the following conditions are true:</P>
<OL>
<LI>The grid is not inside of a <form> tag in the view XML itself.</LI>
<LI>The grid is displaying record selectors.</LI></OL>
<P>A data region in grid mode will display record selectors only if all of the following conditions are true:</P>
<OL>
<LI>The <B>recordselectors</B> attribute of the data region is set to <B>True</B>.</LI>
<LI>The user browsing the view is logged in and is not in the Anonymous security group. </LI>
<LI>The user has Author permissions or higher on the table to which the data region is bound.</LI>
<LI>The grid is not inside of another data region that has already output a <form> tag (<I>e.g.</I> a data region in update mode).</LI></OL>
<P>In grid mode, the following elements in the data region will be rendered:</P>
<OL>
<LI>The caption of the data region.</LI>
<LI>The jump bar of the data region.</LI>
<LI>All fields and html blocks on the data region. Fields and HTML blocks will not be rendered if either they or one of their parent elements has a <B>displaymodes</B> or <B>displayrole</B> attribute which would cause them to be hidden.</LI>
<LI>The action bar of the data region.</LI></OL>
<P>Other items will not be rendered. For instance, in the following data region, the number of records will not be output:</P>
<BLOCKQUOTE>
<P><ws:dataregion><BR><ws:caption><!--# var recordCount = 0; -->This is the data region caption.</ws:caption><BR><ws:fieldbox><ws:field name="Field1"><ws:caption>First Field</ws:caption></ws:field><BR><!--# recordCount ++--></ws:fieldbox><BR></ws:dataregion><BR><!--# response.write("There were " + recordCount + " records.") --></P></BLOCKQUOTE>
<P>The reason is that in grid mode, the script comment block</P>
<BLOCKQUOTE>
<P><!--# recordCount ++ --></P></BLOCKQUOTE>
<P>is ignored. In order to execute script in every row of a grid, it is necessary to put that script inside of an HTML block. For instance:</P>
<BLOCKQUOTE>
<P><ws:dataregion><BR><ws:caption><!--# var recordCount = 0; -->This is the data region caption.</ws:caption><BR><ws:fieldbox><ws:field name="Field1"><ws:caption>First Field</ws:caption></ws:field><BR><ws:htmlblock grid_style="display:none"><!--# recordCount++--></ws:htmlblock></ws:fieldbox><BR></ws:dataregion><BR><!--# response.write("There were " + recordCount + " records.") --></P></BLOCKQUOTE>
<P><B>Details mode:</B></P>
<P>In details mode, a <form> tag is never be output to the HTML stream. All of the child elements of the data region are rendered, with the exception of elements which are hidden because of the settings of their <B>displaymodes</B> or <B>displayrole</B> attribute. The jump bar, data region caption, and action bar are all rendered in separate rows in an HTML table. All of the other child elements of the data region share the cell in which they are rendered.</P>
<P><B>Update mode:</B></P>
<P>A data region in update mode will output a <form> tag unless it is inside of a <form> tag in the view XML itself. If the data region is inside of another data region which has output a <form> tag, then the inner data region will not be displayed. The formatting of a data region in update mode is the same as a data region in details mode. </P>
<P><B>Attributes of the data region:</B></P>
<P>For some of the attributes of the <ws:dataregion> element, you can specify values using Dataweb substitution syntax. The following attributes of the data region do not support Dataweb substitution syntax:</P>
<BLOCKQUOTE>
<P>displaymodes<BR>displayrole<BR>id<BR>showcaption<BR>sortcaptions<BR>recordselectors<BR>showfilter<BR>jumpbarposition<BR>actionbarposition</P></BLOCKQUOTE>
<P>The following attributes of the <ws:dataregion> element are evaluated before the query for the data region is executed, and before the <B>record</B> object is available:</P>
<BLOCKQUOTE>
<P>defaultmode<BR>pagesize<BR>class<BR>style<BR>grid_caption_class<BR>grid_caption_style<BR>redir_insert</P></BLOCKQUOTE>
<P>The following attributes are evaluated after the query for the data region is executed, and once for each record being displayed:</P>
<BLOCKQUOTE>
<P>redir_update<BR>row_style<BR>row_class<BR>row_alt_style<BR>row_alt_class</P></BLOCKQUOTE>
<P>In insert mode, or if there are no records displayed, the above attributes will never be evaluated.</P>
<P><B>The record object:</B></P>
<P>The values of the current record can be obtained through script by referencing the global object variable <B>record</B>. Each field included within a <ws:dataregion> tag is available as a property of the <B>record</B> object, and its value for the current record is available via the <B>record.fieldname</B> syntax. For lookups to other tables, the value of the field is returned through the following syntax:</P>
<BLOCKQUOTE>
<P>record[lookupfield:displayfield]</P></BLOCKQUOTE>
<P>The <B>record</B> object does not necessarily provide the values of all the fields in the table. The following fields will be available:</P>
<OL>
<LI>All of the <ws:field> tags inside of the data region.</LI>
<LI>All of the fields referenced by <ws:select> tags inside of <ws:field></LI>
<LI>The fields named in the "joinfieldparent" properties of nested data regions</LI></OL>
<P>To make a field available on the record object without displaying it in the data region, add the field to the data region and set its <B>displaymodes</B> attribute to "never". Or, you can put the field inside of the <ws:datasource> tag. For example:</P>
<BLOCKQUOTE>
<P><ws:dataregion><BR><ws:datasource src="addressbook"><BR><ws:field name="username" /><BR></ws:datasource><BR><ws:htmlblock>User name is #record.username#.</ws:htmlblock><BR></ws:dataregion></P></BLOCKQUOTE>
<P>In details and grid mode, the values of the properties of the record object can be changed, but this has no effect on the value displayed for a field in the data region. In update and insert mode, the properties of the record object can be changed, and the values provided will appear as the default values of the editable fields in that data region. If the field is not editable within the data region, and the value of the property on the record object has been modified, then the a hidden field will be included on the form that is submitted. For example:</P>
<BLOCKQUOTE>
<P><ws:dataregion defaultmode="update"><BR><ws:caption><!--# record.Field1 = "New Value" -->Data region caption</ws:caption><BR><ws:fieldbox><ws:field name="Field1" editmodes="none"><BR><ws:caption>You can't edit this, but this is the value which will be submitted</ws:caption></ws:field><BR></ws:fieldbox><BR></ws:dataregion></P></BLOCKQUOTE>
<P>This example will output the following tag to the HTML form:</P>
<BLOCKQUOTE>
<P><input type="hidden" name="Field1"></P></BLOCKQUOTE> |
Last Reviewed | February 20, 2015 14:08:11 |
|