PDA

View Full Version : value of cell data in Grid


bvikram_singh
09-12-2005, 01:52 AM
Hi everybody,

I am new in laszlo application working on grid components. In my application, I want to capture data of cell, when it is clicked. In my sample code given below,for example when cell having value "Homer" is
clicked, I want to capture this value.... Thanks in advance



canvas debug="true" height="250">
<dataset name="contacts">
<myXML>
<person show="simpsons1">
<firstName>Homer</firstName>
<lastName>Simpson</lastName>
</person>
<person show="simpsons2">
<firstName>Marge</firstName>
<lastName>Simpson</lastName>
</person>
<person show="simpsons3">
<firstName>Montgomery</firstName>
<lastName>Burns</lastName>
</person>
</myXML>
</dataset>
<grid multiselect="false" showhlines = "true" showvlines= "true" datapath="contacts:/myXML">
<gridtext doesenter = "true" showheader="false" editable="false" width="100" datapath="@show" >
</gridtext>
<gridtext showheader="false" datapath="firstName/text()" editable="false" width="200">
</gridtext>

<method event="onselect">
<![CDATA[
var id = this.getSelection().p.attributes.show;
Debug.write( "ID " + id );

]]>
</method>

</grid>
</canvas>

mfrony
09-13-2005, 04:31 PM
You can solve this problem by using a datapointer. Btw, you can make your code easier to read for other users by using vB Code tags. There's a help link to it on the left column when you post your query.


<canvas debug="true" height="250">

<dataset name="contacts">
<myXML>
<person show="simpsons1">
<firstName>Homer</firstName>
<lastName>Simpson</lastName>
</person>
<person show="simpsons2">
<firstName>Marge</firstName>
<lastName>Simpson</lastName>
</person>
<person show="simpsons3">
<firstName>Montgomery</firstName>
<lastName>Burns</lastName>
</person>
</myXML>
</dataset>

<grid multiselect="false" showhlines = "true" showvlines= "true" datapath="contacts:/myXML">
<gridtext doesenter = "true" showheader="false" editable="false" width="100" datapath="@show" >
</gridtext>
<gridtext showheader="false" datapath="firstName/text()" editable="false" width="200">
</gridtext>

<method event="onselect">
<![CDATA[
// create a new datapointer
// and move the pointer to firstName
//
var dp_foo = new LzDatapointer(this);
dp_foo.setPointer(this.getSelection().p);
dp_foo.selectChild();

// get the value you need
//
var firstName = dp_foo.getNodeText();
var id = this.getSelection().p.attributes.show;

Debug.write("firstName ", firstName );
Debug.write( "ID " + id );
]]>
</method>
</grid>

</canvas>

bvikram_singh
09-13-2005, 07:33 PM
Thanks a lot, Mfrony