PDA

View Full Version : catching the event: "onclick of caption of a gridcolumn"


MBachstein
10-28-2008, 04:58 AM
Hello,

does anybody know how I can catch the event if someone has clicked on the caption of a gridcolumn?

Kind Regards,
Marc

rcyeager
10-28-2008, 06:50 AM
What do you mean by caption? This?


<canvas width="100%" height="100%" bgcolor="0xACCEF1" debug="true">
<dataset name="rec">
<rec>
<reg id="1"/>
<reg id="2"/>
<reg id="3"/>
<reg id="4"/>
<reg id="5"/>
<reg id="6"/>
<reg id="7"/>
<reg id="8"/>
<reg id="9"/>
</rec>
</dataset>

<handler name="oninit">
new LzDelegate(this, "handleClick", regs.header.hcontent.subviews[0].mybutton, "onclick");
</handler>

<method name="handleClick">
Debug.write("CLICKED!");
</method>

<grid id="regs" contentdatapath="rec:/rec/reg" x="5" y="5">
<gridcolumn width="50">id<text datapath="@id"/>
</gridcolumn>
</grid>

</canvas>


Robert Yeager
http://www.qrowd.com
http://www.cooqy.com

MBachstein
10-28-2008, 07:23 AM
Yes! Exactly. :)

Thank you very much, Robert!

MBachstein
10-28-2008, 08:40 AM
I have still another question.

In my grid the gridcolumns are dynamically generated.

So I have n delegates for n gridcolumns:

for (var i=0; i < n; z++) {
new LzDelegate(this, "handleClick", this.header.hcontent.subviews[i].mybutton, "onclick");
}

But how do I find out which column caption is clicked? Does anybody know how I can transfer an argument (like here: i) in an LzDelegate?

Then I could use this method:

<method name="handleClick" args="column">
Debug.write("Column "+column+" clicked.");
</method>

Kind Regards,
Marc

rcyeager
10-28-2008, 08:56 AM
The onclick handler receives the view that was clicked, so no problem!


<canvas width="100%" height="100%" bgcolor="0xACCEF1" debug="true">
<dataset name="rec">
<rec>
<reg id="1"/>
<reg id="2"/>
<reg id="3"/>
<reg id="4"/>
<reg id="5"/>
<reg id="6"/>
<reg id="7"/>
<reg id="8"/>
<reg id="9"/>
</rec>
</dataset>

<handler name="oninit">
new LzDelegate(this, "handleClick", regs.header.hcontent.subviews[0].mybutton, "onclick");
</handler>

<method name="handleClick" args="v">
Debug.write("CLICKED!");
Debug.inspect(v);
</method>

<grid id="regs" contentdatapath="rec:/rec/reg" x="5" y="5">
<gridcolumn width="50">id<text datapath="@id"/>
</gridcolumn>
</grid>

</canvas>


Robert Yeager
http://www.qrowd.com
http://www.cooqy.com