1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340
|
<refentry id="vc_data_grid">
<refmeta>
<refentrytitle>data-grid</refentrytitle>
<refmiscinfo>vspx_control</refmiscinfo>
</refmeta>
<refnamediv>
<refname>data-grid</refname>
<refpurpose>Scrollable databound multi-row control.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis id="vc_syn_data_grid">
<funcprototype id="vc_proto_data_grid">
<funcdef>
<<function>data-grid</function> <attribute>
<parameter>name</parameter> (required) </attribute>
<attribute>
<parameter>annotation</parameter> (optional) </attribute>
<attribute>
<parameter>initial-enable</parameter> (optional) </attribute>
<attribute>
<parameter>enabled</parameter> (optional) </attribute>
<attribute>
<parameter>instantiate</parameter> (optional) </attribute>
<attribute>
<parameter>control-udt</parameter> (optional) </attribute>
<attribute>
<parameter>xsd-stub-xhtml</parameter> (optional) </attribute>
<attribute>
<parameter>width</parameter> (optional) </attribute>
<attribute>
<parameter>height</parameter> (optional) </attribute>
<attribute>
<parameter>data</parameter> (optional) </attribute>
<attribute>
<parameter>meta</parameter> (optional) </attribute>
<attribute>
<parameter>nrows</parameter> (optional) </attribute>
<attribute>
<parameter>sql</parameter> (required) </attribute>
<attribute>
<parameter>scrollable</parameter> (optional) </attribute>
<attribute>
<parameter>cursor-type</parameter> (optional) </attribute>
<attribute>
<parameter>edit</parameter> (optional) </attribute>
<attribute>
<parameter>debug-srcfile</parameter> (optional) </attribute>
<attribute>
<parameter>debug-srcline</parameter> (optional) </attribute>
<attribute>
<parameter>debug-log</parameter> (optional) </attribute>
/></funcdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1 id="vc_desc_data_grid">
<title>Description</title>
<para>
<para>This is the generic multi-row database view control. It is used to show repeating data, as from tables
or procedure views. Allows scrolling (paging) editing the data; adding a row or removal of existing rows.
Usually this control generates a PL scrollable cursor of type as specified. The number of rows shown are
configurable via nrows attribute. Note also that column children elements are optional; they can be omitted
so then VSPX engine will compute them from specified SQL statement in 'sql' attribute.</para>
<para>Specific to this control is to have row-template and frame-template, these are to present repeating and non-repeating groups of children elements. The frame-template will usually
have a 'rowset' placeholder to designate the place where repeating group (row-template) will be instantiated. The control expects to find child controls with specific names. for scrolling buttons - [data-grid name]'_prev' and [data-grid name]'_next'; for editing buttons - [data-grid name]'_edit' and [data-grid name]'_delete'.</para>
</para>
</refsect1>
<refsect1 id="vc_attrs_data_grid">
<title>Attributes</title>
<formalpara>
<title>name = <link linkend="vc_type_SqlName">SqlName</link>
</title>
<para>A page level unique name identifying a control.</para>
</formalpara>
<formalpara>
<title>annotation</title>
<para>A human readable comment.</para>
</formalpara>
<formalpara>
<title>initial-enable = <link linkend="vc_type_CalculateableValue">CalculateableValue</link>
</title>
<para>Determines whether a control is initially visible. True by default. Could be data-bound to an SQL expression.</para>
</formalpara>
<formalpara>
<title>enabled = <link linkend="vc_type_CalculateableValue">CalculateableValue</link>
</title>
<para>Determines whether a control is visible. True by default. Could be data-bound to an SQL expression.</para>
</formalpara>
<formalpara>
<title>instantiate = <link linkend="vc_type_CalculateableValue">CalculateableValue</link>
</title>
<para>Determines whether a control instantiate its children. It is true by default. It could be data-bound to an SQL expression. Unlike most of calcucateable attributes, the value of this attribute for a control is calcluated before calling 'on-init' event handler of the control; other values are calculated before calling 'before-data-bind' event handler.</para>
</formalpara>
<formalpara>
<title>control-udt = <link linkend="vc_type_SqlName">SqlName</link>
</title>
<para>At run time every control is represented as an instance of some user-defined type (UDT). VSPX compiles selects the UDT to use depending on name of the XML element that represents the control and maybe some of its attributes. In some specific cases the application developer may instruct VSPX compiler to use some other UDT, e.g. an application-specific UDT that is derived from the preset one. If specified, the value of 'control-udt' attribute should be equal to the name of the desired target UDT.</para>
</formalpara>
<formalpara>
<title>xsd-stub-xhtml</title>
<para>This attribute is for internal use only. It has no effect if added to the source VSPX file.</para>
</formalpara>
<formalpara>
<title>width</title>
<para>Visible width of the control when it is displayed in WYSIWYG tools when the source VSPX text is edited.
The value of this attribute will not be used when the resulting HTML is rendered.</para>
</formalpara>
<formalpara>
<title>height</title>
<para>Visible width of the control when it is displayed in WYSIWYG tools when the source VSPX text is edited.
The value of this attribute will not be used when the resulting HTML is rendered.</para>
</formalpara>
<formalpara>
<title>data = <link linkend="vc_type_CalculateableValue">CalculateableValue</link>
</title>
<para>Expression which returns an array of rowset data, this is an alternative to specifying an SQL expression. The result then will be used to instantiate
the repeating group. An example of such data is the result returned by 'exec' function:</para>
<programlisting>
(
("ALFKI" "Alfreds Futterkiste" "030-0074321" )
("ANATR" "Ana Trujillo Emparedados y helados" "(5) 555-4729" )
)
</programlisting>
</formalpara>
<formalpara>
<title>meta = <link linkend="vc_type_CalculateableValue">CalculateableValue</link>
</title>
<para>This works with combination of data attribute, this expression must return an array of ro metadata. So when this is specified it needs to be an expression returning meta-data for columns. In practice this is the same as 1st element of metadata returned by 'exec()' :</para>
<programlisting>
(
("CustomerID" 182 0 5 0 1 1 "Demo" "CustomerID" "demo" "Customers" 0 )
("CompanyName" 182 0 40 1 1 1 "Demo" "CompanyName" "demo" "Customers" 0 )
("Phone" 182 0 24 1 1 1 "Demo" "Phone" "demo" "Customers" 0 )
)
</programlisting>
<para>
for details of metadata see 'exec()' function description.</para>
</formalpara>
<formalpara>
<title>nrows = <link linkend="vc_type_CalculateableValue">CalculateableValue</link>
</title>
<para>The maximum number of replicas of the row template to be made for rows selected.
This is like the rowset size for a scrollable cursor.</para>
</formalpara>
<formalpara>
<title>sql = <link linkend="vc_type_SqlCode">SqlCode</link>
</title>
<para>The select statement that gets the data.
Parameters to the statement MUST be specified as SQL identifiers prefixed with a colon (named parameter).
The values are given in the control's vspx:param children. These specify the parameter name and a data bound expression for the value.
</para>
</formalpara>
<formalpara>
<title>scrollable</title>
<para>The setting controls whether next and previous page buttons are presented. This can be on even if the cursor is not scrollable as such.</para>
</formalpara>
<formalpara>
<title>cursor-type</title>
<table>
<title>Allowed values of the 'cursor-type' attribute</title>
<tgroup cols="2">
<tbody>
<row>
<entry>static</entry>
<entry>
<para>A static cursor is used.</para>
</entry>
</row>
<row>
<entry>dynamic</entry>
<entry>
<para>A dynamic cursor is used.</para>
</entry>
</row>
<row>
<entry>keyset</entry>
<entry>
<para>A keyset cursor is used.</para>
</entry>
</row>
</tbody>
</tgroup>
</table>
</formalpara>
<formalpara>
<title>edit = <link linkend="vc_type_CalculateableValue">CalculateableValue</link>
</title>
<para>Flags whether editing features are enabled on data grid control</para>
</formalpara>
<formalpara>
<title>debug-srcfile</title>
<para>URI of the source document where the tag comes from.</para>
</formalpara>
<formalpara>
<title>debug-srcline</title>
<para>Line number in the source document where the tag comes from.</para>
</formalpara>
<formalpara>
<title>debug-log</title>
<para>This defines what sort of data are saved to the debugging log.
</para>
</formalpara>
</refsect1>
<refsect1 id="vc_udt_data_grid">
<title>Declaration of type vspx_data_grid</title>
<para>
Scrollable, Multi-Row data grid Class
</para>
<screen>
create type vspx_data_grid under vspx_form
as (
dg_nrows int default -1, -- how many rows to show on single page
dg_scrollable int default 0, -- scroll on form is enabled
dg_editable int default 1, -- disable edit/add on whole grid
dg_row_meta any, -- metadata
dg_row_data any, -- the data for procedure binding
dg_current_row vspx_row_template, -- current row template
dg_rowno_edit int default null, -- last edited row in result set, to re-display the edit box on error
dg_rows_fetched int default 0, -- these are to keep state for scrolling
dg_prev_bookmark any default null,
dg_last_bookmark any default null
) temporary self as ref
method vc_templates_clean () returns any,
constructor method vspx_data_grid (name varchar, parent vspx_control),
overriding method vc_set_view_state (e vspx_event) returns any,
overriding method vc_view_state (stream any, n int) returns any
</screen>
</refsect1>
<refsect1 id="vc_ex_data_grid">
<title>Examples</title>
<example id="vc_ex_data_grid__0">
<title>
Editable multi-row data grid based on data-grid control
</title>
<para>
<?xml version="1.0"?>
<!--
-
- $Id: data_grid__0.vspx,v 1.2 2006/08/16 00:04:15 source Exp $
-
- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
- project.
-
- Copyright (C) 1998-2006 OpenLink Software
-
- This project is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; only version 2 of the License, dated June 1991.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-
This example will show a list of customers from the Northwind demo database.
Allows editing, addtion and removal of existing records.
</para>
<screen>
<v:page name="data_grid__0" xmlns:v="http://www.openlinksw.com/vspx/">
<html>
<body>
<v:data-grid name="dg" nrows="5" sql="select CustomerID, CompanyName, Phone from Demo.demo.Customers where CustomerId like :mask" cursor-type="keyset" edit="1">
<v:param name="mask" value="'%'"/>
<v:template name="t1" type="frame">
<div>
<div>
Action
<v:label name="l1" value="--(control.vc_parent as vspx_data_grid).dg_row_meta[0]"/>
<v:label name="l2" value="--(control.vc_parent as vspx_data_grid).dg_row_meta[1]"/>
<v:label name="l3" value="--(control.vc_parent as vspx_data_grid).dg_row_meta[2]"/>
</div>
<v:rowset/>
<v:form type="add"/>
<div>
<v:button name="dg_prev" action="simple" value="&lt;&lt;"/>
<v:button name="dg_next" action="simple" value="&gt;&gt;"/>
</div>
</div>
</v:template>
<v:template name="t2" type="row">
<div>
<v:button name="dg_edit" action="simple" value="Edit"/>
<v:button name="dg_delete" action="simple" value="Delete">
<v:on-post>
delete from Demo.demo.Customers where CustomerID = self.dg.dg_current_row.te_rowset[0];
self.dg.vc_data_bind (e);
</v:on-post>
</v:button>
<v:label name="label1" value="--(control.vc_parent as vspx_row_template).te_rowset[0]"/>
<v:label name="label2" value="--(control.vc_parent as vspx_row_template).te_rowset[1]"/>
<v:label name="label3" value="--(control.vc_parent as vspx_row_template).te_rowset[2]"/>
</div>
</v:template>
<v:template name="t3" type="if-not-exists">
<div>No rows selected</div>
</v:template>
<v:template name="t4" type="edit">
<v:form name="u1" type="update" table="Demo.demo.Customers" if-not-exists="insert">
<v:key column="CustomerID" value="--self.dg.dg_current_row.te_rowset[0]" default="null"/>
<v:template type="if-exists" name="t5">
<div>
<v:button name="b1" action="submit" value="Update"/>
<input type="submit" name="b2" value="Cancel"/>
<v:text name="c_id1" column="CustomerID"/>
<v:text name="c_name1" column="CompanyName"/>
<v:text name="c_phone1" column="Phone"/>
</div>
</v:template>
</v:form>
</v:template>
<v:template name="t6" type="add">
<v:form type="update" name="a1" table="Demo.demo.Customers" if-not-exists="insert">
<v:key column="CustomerID" value="--''" default="null"/>
<v:template name="t7" type="if-exists">
<v:button name="b3" action="submit" value="Add"/>
<v:text name="c_id2" column="CustomerID"/>
<v:text name="c_name2" column="CompanyName"/>
<v:text name="c_phone2" column="Phone"/>
</v:template>
</v:form>
</v:template>
</v:data-grid>
</body>
</html>
</v:page>
</screen>
</example>
</refsect1>
</refentry>
|