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
|
<?xml version="1.0"?>
<!--
-
- $Id: vx_s_12_sample.vspx,v 1.2 2006/08/16 00:04:14 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
-
-
-->
<v:page name="data_set_page" xmlns:v="http://www.openlinksw.com/vspx/" >
<v:variable name="all_cols" type="xml" default="null" persist="pagestate"/>
<v:variable name="orderby" type="xml" default="null" persist="pagestate"/>
<v:on-init><![CDATA[
if (self.all_cols is null)
self.all_cols := xtree_doc ('<table><column name="First"/><column name="Second"/><column name="Third"/><column name="Fourth"/></table>');
if (self.orderby is null)
self.orderby := xtree_doc ('<order-by/>');
]]></v:on-init>
<html>
<head>
<title>Editing of ordered list</title>
</head>
<body bgcolor="#ffffff">
<v:form name="fadd" type="simple">
<v:data-list name="ladd" list-document="--self.all_cols" list-match="/table/column" list-key-path="@name" list-value-path="@name">
</v:data-list>
<v:button name="badd" action="submit" value="append to the order-by list">
<v:on-post><![CDATA[
declare added_name varchar;
added_name := get_keyword ('ladd', e.ve_params, NULL);
if (xpath_eval (sprintf('count(/order-by/column[@name="%s"])', added_name), self.orderby) = 0)
{
declare oby, ncol any;
oby := self.orderby;
ncol := xpath_eval (sprintf('/table/column[@name="%s"]', added_name), self.all_cols);
XMLAppendChildren (xpath_eval ('/order-by', oby), ncol);
self.orderby := oby;
}
self.vc_find_descendant_control('ds').vc_data_bind(e);]]>
</v:on-post>
</v:button>
</v:form>
<v:data-set name="ds" data="--xpath_eval ('/order-by/column', self.orderby, 0)" meta="--get_xml_meta()" nrows="10" scrollable="0" width="80">
<v:template name="template1" type="simple" name-to-remove="table" set-to-remove="bottom">
<h4><v:label name="label03" value="--(control.vc_parent.vc_parent as vspx_data_set).ds_rows_offs" format="That Is Header - rowset offset : %d" width="80"/></h4>
<table width="400" border="2" cellspacing="0" cellpadding="0">
<tr>
<td align="center"><b>#</b></td>
<td align="center"><b>Column name</b></td>
<td align="center"><b>Actions</b></td>
</tr>
</table>
</v:template>
<v:template name="template2" type="repeat" name-to-remove="" set-to-remove="">
<v:template name="template7" type="if-not-exists" name-to-remove="table" set-to-remove="both">
<table width="400" border="2" cellspacing="0" cellpadding="0">
<tr>
<td align="center" colspan="5">
<b>The order-by list is empty</b>
</td>
</tr>
</table>
</v:template>
<v:template name="template4" type="browse" name-to-remove="table" set-to-remove="both">
<table width="400" border="1" cellspacing="2" cellpadding="0">
<tr>
<td align="right" nowrap="1">
<v:label name="label5ctr" value="--(control.vc_parent as vspx_row_template).te_ctr + (control.vc_parent.vc_parent as vspx_data_set).ds_rows_offs + 1" format="%d" width="80"/>.
</td>
<td align="left" nowrap="1">
<v:label name="label5" element-value="--(control.vc_parent as vspx_row_template).te_rowset" element-place="@name" format="%s"/>
</td>
<td align="left" nowrap="1">
<v:button name="del" action="simple" value="Remove from list" style="url">
<v:on-init>control.vc_parent.vc_focus := 1;</v:on-init>
<v:on-post>
declare c any;
c := (control.vc_parent as vspx_row_template).te_rowset;
XMLReplace(self.orderby, c, null);
self.vc_find_descendant_control('ds').vc_data_bind(e);
</v:on-post>
</v:button>
<v:button name="up" action="simple" value="Move UP" style="url">
<v:on-init>control.vc_parent.vc_focus := 1;</v:on-init>
<v:on-post>
declare c, cprec any;
c := (control.vc_parent as vspx_row_template).te_rowset;
cprec := xpath_eval('preceding-sibling::*',c);
if (cprec)
{
XMLInsertAfter(c,cprec);
XMLReplace(self.orderby, xpath_eval('preceding-sibling::*',c), null);
self.vc_find_descendant_control('ds').vc_data_bind(e);
}
</v:on-post>
</v:button>
<v:button name="dn" action="simple" value="Move DOWN" style="url">
<v:on-init>control.vc_parent.vc_focus := 1;</v:on-init>
<v:on-post>
declare c, cfoll any;
c := (control.vc_parent as vspx_row_template).te_rowset;
cfoll := xpath_eval('following-sibling::*',c);
if (cfoll)
{
XMLInsertAfter(cfoll,c);
XMLReplace(self.orderby, xpath_eval('preceding-sibling::*',cfoll), null);
self.vc_find_descendant_control('ds').vc_data_bind(e);
}
</v:on-post>
</v:button>
</td>
</tr>
</table>
</v:template>
</v:template>
<v:template name="template3" type="simple" name-to-remove="table" set-to-remove="top">
<table width="400" border="1" cellspacing="2" cellpadding="0">
<tr>
<td colspan="3">
<v:button name="ds_prev" action="simple" value="<<" />
<v:button name="ds_next" action="simple" value=">>" />
</td>
</tr>
</table>
</v:template>
</v:data-set>
</body>
</html>
</v:page>
|