Thank you Cary!!!
Very useful! I hope openlaszlo support this in the next release...
Only a small bug in the sample code you posted:
in the method "onRowDoubleClicked" you defined the var useridId
but in the next rows you called it userId.
Here the code with the small bug fixed:
=================================================================
<dcGrid name="userGrid" datapath="local:classroot.getUsersDS:/Users"
contentdatapath="User"
width="40%" height="100%" showhscroll="true" bgcolor="0xCAE1FF"
>
<method event="onRowDoubleClicked" args="selectedRow">
parent.viewingIndex = this.getIndexForItem(selectedRow) ;
// Debug.write('grid::onRowDoubleClicked: viewing index in ' +
parent.name + ": " + parent.viewingIndex + " (" + this.lastSelectedRow
+ ")" );
// Find the id of the selected row
var useridId = selectedRow.datapath.xpathQuery( "UserId/text()" ) ;
// Debug.write( "grid::onRowDoubleClicked: selectedRow.datapath: (" +
selectedRow.datapath.class.name + ") " +
selectedRow.datapath.serialize() ) ;
Debug.write( "grid::onRowDoubleClicked: selected user Id is " +
useridId ) ;
if ( useridId.length > 0 )
{
// Do whatever you want at this point; you have a valid user Id....
}
</method>
<gridcolumn width="${parent.width /2 }">Last Name
<text datapath="LastName/text()"/>
</gridcolumn>
<gridcolumn width="${parent.width /2 }">First Name
<text datapath="FirstName/text()"/>
</gridcolumn>
</dcGrid>
=================================================================
Bye!
Luca Ritossa
Cary Clark ha scritto:
The dblclick doesn't fire for the grid or grid row. IT REALLY SHOULD.
I got this code from a guy on one of the Laszlo forums and tweaked it a
bit. I forget his name, so credit goes to him whoever he is:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE canvas SYSTEM
"http://www.laszlosystems.com/lps/tools/lzx.dtd">
<library>
<include href="" />
<include href=""/>
<class name="dcGrid" extends="grid">
<attribute name="lastSelectionTime" value="0"/>
<attribute name="lastSelectedRow" value="-1"/>
<attribute name="onRowDoubleClicked" value="null"/>
<method name="itemSelected" args="item" event="onselect">
<![CDATA[
var selectionTime = (new Date).getTime() ;
var currentRow = this.getIndexForItem(item) ;
//Debug.write( "dcGrid::itemSelected: item: " + item ) ;
//Debug.write( "dcGrid::itemSelected: currentRow: " + currentRow ) ;
if ( (selectionTime - this.lastSelectionTime) <= 500
// adjust this as desired...
&& currentRow == lastSelectedRow )
{
if(this.onRowDoubleClicked)
this.onRowDoubleClicked.sendEvent(item) ;
}
this.lastSelectedRow = currentRow ;
this.lastSelectionTime = selectionTime ;
]]>
</method>
</class>
</library>
Here is a sample to list some users:
=======================
<dcGrid name="userGrid"
datapath="local:classroot.getUsersDS:/Users" contentdatapath="User"
width="40%" height="100%" showhscroll="true"
bgcolor="0xCAE1FF" >
<method event="onRowDoubleClicked"
args="selectedRow">
parent.viewingIndex =
this.getIndexForItem(selectedRow) ;
// Debug.write('grid::onRowDoubleClicked:
viewing index in ' + parent.name + ": " + parent.viewingIndex + " (" +
this.lastSelectedRow + ")" );
// Find the id of the selected row
var useridId = selectedRow.datapath.xpathQuery(
"UserId/text()" ) ;
// Debug.write( "grid::onRowDoubleClicked:
selectedRow.datapath: (" + selectedRow.datapath.class.name + ") " +
selectedRow.datapath.serialize() ) ;
Debug.write( "grid::onRowDoubleClicked:
selected user Id is " + userId ) ;
if ( userId.length > 0 )
{
// Do whatever you want at this point; you
have a valid user Id....
}
</method>
<gridcolumn width="${parent.width /2 }">Last
Name
<text datapath="LastName/text()"/>
</gridcolumn>
<gridcolumn width="${parent.width /2 }">First
Name
<text datapath="FirstName/text()"/>
</gridcolumn>
</dcGrid>
Here's some sample XML
=======================
<Users>
<User>
<UserId>1</UserId>
<FirstName>Donald</FirstName>
<LastName>Duck</LastName>
<Address1>1332 Fox Run</Address1>
<Address2/>
<City>Disneyland</City>
<State>Confusion</State>
<Zip>73003</Zip>
<Country>USA</Country>
<Phone1>405-123-4567</Phone1>
<Phone2>405-780-3433</Phone2>
<EmailAddress>[EMAIL PROTECTED]</EmailAddress>
</User>
</Users>
=======================
Luca Ritossa wrote:
I'd like to intercept
the dblclick event when I dblclick on a grid's row.
No success. Nothing happen.
I've setted
code:
<gridtext ... clickable="true">
<method event="ondblclick">
Debug.write("double clicked");
</method>
</gridtext>
I'm sure I forgot some code...
Any suggestions will be appreciated.
Luca Ritossa
_______________________________________________
Laszlo-user mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-user
|
_______________________________________________
Laszlo-user mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-user