PDA

View Full Version : mouse clicks in a grid


mcgaffin
08-24-2004, 06:55 AM
Here is a grid with an onclick event:


<canvas debug="true">
<dataset name="griddata">
<result>
<item brand="Continental" model="GP3000" color="black" />
<item brand="Vittoria" model="Rubino" color="black/red" />
</result>
</dataset>

<grid datapath="griddata:/result">
<method event="onclick">
debug.write("clicked the grid");
</method>
</grid>
</canvas>


It appears that the onclick event is only received by the grid if I click in an empty area of the grid, rather than on one of the rows. I have noticed that I can define an onclick method for a gridcolumn and handle the clicks that way. However, with the data I am using, I don't know what columns are in my dataset. One set could be


<result>
<item brand="Continental" model="GP3000" color="black" />
</result>


while in the same interface I might get a dataset like this:


<result>
<item category="enterprise" office="Tulsa" department="Sales" />
</result>


Is it possible to have one grid that can display both datasets and receive onclick events at the grid level? Alternatively, is there a better way to receive an event when a grid selection changes?

Thanks.

- david

antun
08-24-2004, 08:27 AM
Is it possible to have one grid that can display both datasets and receive onclick events at the grid level?

Yes - you can use the onselect event of grid, which it inherits from node:


<grid datapath="griddata:/result">
<method event="onselect">
debug.write("clicked the grid");
</method>
</grid>


I can understand why you were confused; onselect doesn't have any special meaning in the LZX Reference page for grid. There is a bug filed against this. In general, the onselect event is used in the Laszlo components when the selection of a component is changed.

Take care,

Antun