OLaszloFan
04-19-2007, 03:05 PM
Hi All:
I need your help to update the Contacts Example so that a Grid Component is used instead of text views.
So far I have adjusted the code to use windows instead of plain replicated text views.
If you run the posted code you will see that I am about half way through the conversion.
You will see a New Entry Button, a Grid and then the original replicated data text views from the original databinding example. This can be linked to an external database.
What I am hoping for is to allow the user to add, update and delete contact records while using windows and the grid component.
The lower duplicate text rows which are below the grid would then be eliminated.
Problems:
Need help defining the correct grid row onselect code so that the updateContact window will pop up just like it does for the original text rows.
Any help would be greatly appreciated!!!!
Patrick
<!DOCTYPE canvas PUBLIC "LZX" "http://127.0.0.1:8080/lps-3.3.3/tools/lzx.dtd">
<!-- *** -->
<!-- First try at converting OpenLaszlo Contacts Example using PHP service-->
<!-- Objective is to exchange contact list with Grid Component list and maintain simular functionality-->
<!-- Problems: -->
<!-- Contacts example allows the user to click on a text record to show a update view -->
<!-- Need Grid help to enable the user to click on a row within the grid to show a update window -->
<!-- *** -->
<canvas width="100%" height="100%" bgcolor="#D4D0C8" debug="true">
<dataset name="dset" src="http://www.yoursite/getcontacts.php" request="true" type="http"/>
<dataset name="dsSendData" request="false" src="http://www.yoursite/contactmgr.php" type="http"/>
<class name="contactview" extends="window" title="My Window" visible="false" closeable="true" x="20" width="400" height="160">
<text name="pk" visible="false" datapath="@email"/>
<text y="10">First Name:</text>
<edittext name="firstName" datapath="@firstName" x="80" y="10"/>
<text y="35">Last Name:</text>
<edittext name="lastName" datapath="@lastName" x="80" y="35"/>
<text y="60">Phone:</text>
<edittext name="phone" datapath="@phone" x="80" y="60"/>
<text y="85">Email:</text>
<edittext name="email" datapath="@email" x="80" y="85"/>
<method name="sendData" args="action">
var d=canvas.datasets.dsSendData;
var p=new LzParam();
p.addValue("action", action, true);
p.addValue("pk", pk.getText(), true);
p.addValue("firstName", firstName.getText(), true);
p.addValue("lastName", lastName.getText(), true);
p.addValue("phone", phone.getText(), true);
p.addValue("email", email.getText(), true);
d.setQueryString(p);
d.doRequest();
</method>
</class>
<simplelayout axis="y"/>
<view>
<simplelayout axis="y"/>
<button onclick="parent.newContact.setVisible(!parent.newContact.vi sible);">New Entry...</button>
<grid name="list" showhlines="true" showvlines="true" datapath="dset:/*" onclick="parent.updateContact.setVisible(!parent.updateCont act.visible);">
<gridtext textalign="center" editable="false" width="50" datapath="position()" resizable="false" sortable="false">No.</gridtext>
<gridtext textalign="center" editable="true" datapath="@firstName">First Name:</gridtext>
<gridtext textalign="center" editable="true" datapath="@lastName">Last Name:</gridtext>
<gridtext textalign="center" editable="true" datapath="@phone">Phone:</gridtext>
<gridtext textalign="center" editable="true" width="150" datapath="@email">Email:</gridtext>
</grid>
<contactview name="newContact" title="New Contact" datapath="new:/contact">
<button width="80" x="200" y="10">Add
<method event="onclick">
parent.sendData("insert"); // INSERT
parent.datapath.updateData();
var dp = canvas.datasets.dset.getPointer();
dp.selectChild();
dp.addNodeFromPointer( parent.datapath );
parent.setVisible(false);
parent.setDatapath("new:/contact");
Debug.write(localdata.serialize());
</method>
</button>
</contactview>
</view>
<view datapath="dset:/phonebook/contact">
<simplelayout axis="y"/>
<view name="list" onclick="parent.updateContact.setVisible(!parent.updateCont act.visible);">
<simplelayout axis="x"/>
<text datapath="@firstName"/>
<text datapath="@lastName"/>
<text datapath="@phone"/>
<text datapath="@email"/>
</view>
<contactview name="updateContact" title="Update Contact" >
<button width="80" x="200" y="10">Update
<method event="onclick">
parent.sendData("update"); // UPDATE
parent.parent.datapath.updateData();
</method>
</button>
<button width="80" x="200" y="40">Delete
<method event="onclick">
parent.sendData("delete"); // DELETE
parent.parent.datapath.deleteNode();
</method>
</button>
</contactview>
</view>
</canvas>
I need your help to update the Contacts Example so that a Grid Component is used instead of text views.
So far I have adjusted the code to use windows instead of plain replicated text views.
If you run the posted code you will see that I am about half way through the conversion.
You will see a New Entry Button, a Grid and then the original replicated data text views from the original databinding example. This can be linked to an external database.
What I am hoping for is to allow the user to add, update and delete contact records while using windows and the grid component.
The lower duplicate text rows which are below the grid would then be eliminated.
Problems:
Need help defining the correct grid row onselect code so that the updateContact window will pop up just like it does for the original text rows.
Any help would be greatly appreciated!!!!
Patrick
<!DOCTYPE canvas PUBLIC "LZX" "http://127.0.0.1:8080/lps-3.3.3/tools/lzx.dtd">
<!-- *** -->
<!-- First try at converting OpenLaszlo Contacts Example using PHP service-->
<!-- Objective is to exchange contact list with Grid Component list and maintain simular functionality-->
<!-- Problems: -->
<!-- Contacts example allows the user to click on a text record to show a update view -->
<!-- Need Grid help to enable the user to click on a row within the grid to show a update window -->
<!-- *** -->
<canvas width="100%" height="100%" bgcolor="#D4D0C8" debug="true">
<dataset name="dset" src="http://www.yoursite/getcontacts.php" request="true" type="http"/>
<dataset name="dsSendData" request="false" src="http://www.yoursite/contactmgr.php" type="http"/>
<class name="contactview" extends="window" title="My Window" visible="false" closeable="true" x="20" width="400" height="160">
<text name="pk" visible="false" datapath="@email"/>
<text y="10">First Name:</text>
<edittext name="firstName" datapath="@firstName" x="80" y="10"/>
<text y="35">Last Name:</text>
<edittext name="lastName" datapath="@lastName" x="80" y="35"/>
<text y="60">Phone:</text>
<edittext name="phone" datapath="@phone" x="80" y="60"/>
<text y="85">Email:</text>
<edittext name="email" datapath="@email" x="80" y="85"/>
<method name="sendData" args="action">
var d=canvas.datasets.dsSendData;
var p=new LzParam();
p.addValue("action", action, true);
p.addValue("pk", pk.getText(), true);
p.addValue("firstName", firstName.getText(), true);
p.addValue("lastName", lastName.getText(), true);
p.addValue("phone", phone.getText(), true);
p.addValue("email", email.getText(), true);
d.setQueryString(p);
d.doRequest();
</method>
</class>
<simplelayout axis="y"/>
<view>
<simplelayout axis="y"/>
<button onclick="parent.newContact.setVisible(!parent.newContact.vi sible);">New Entry...</button>
<grid name="list" showhlines="true" showvlines="true" datapath="dset:/*" onclick="parent.updateContact.setVisible(!parent.updateCont act.visible);">
<gridtext textalign="center" editable="false" width="50" datapath="position()" resizable="false" sortable="false">No.</gridtext>
<gridtext textalign="center" editable="true" datapath="@firstName">First Name:</gridtext>
<gridtext textalign="center" editable="true" datapath="@lastName">Last Name:</gridtext>
<gridtext textalign="center" editable="true" datapath="@phone">Phone:</gridtext>
<gridtext textalign="center" editable="true" width="150" datapath="@email">Email:</gridtext>
</grid>
<contactview name="newContact" title="New Contact" datapath="new:/contact">
<button width="80" x="200" y="10">Add
<method event="onclick">
parent.sendData("insert"); // INSERT
parent.datapath.updateData();
var dp = canvas.datasets.dset.getPointer();
dp.selectChild();
dp.addNodeFromPointer( parent.datapath );
parent.setVisible(false);
parent.setDatapath("new:/contact");
Debug.write(localdata.serialize());
</method>
</button>
</contactview>
</view>
<view datapath="dset:/phonebook/contact">
<simplelayout axis="y"/>
<view name="list" onclick="parent.updateContact.setVisible(!parent.updateCont act.visible);">
<simplelayout axis="x"/>
<text datapath="@firstName"/>
<text datapath="@lastName"/>
<text datapath="@phone"/>
<text datapath="@email"/>
</view>
<contactview name="updateContact" title="Update Contact" >
<button width="80" x="200" y="10">Update
<method event="onclick">
parent.sendData("update"); // UPDATE
parent.parent.datapath.updateData();
</method>
</button>
<button width="80" x="200" y="40">Delete
<method event="onclick">
parent.sendData("delete"); // DELETE
parent.parent.datapath.deleteNode();
</method>
</button>
</contactview>
</view>
</canvas>