Get ID of clicked element

asked 2021-02-17 02:51:21 +0800

Leloup gravatar image Leloup
3 1

updated 2021-02-17 12:19:19 +0800

cor3000 gravatar image cor3000
5673 2 7
ZK Team


I have a row with onClick Event :

<row id="${each.id}" onClick="@command('showDetails')" >

And a method receiver for it :

public void showDetails() {
     System.out.println("clic ");       

How can i get the id of the row clicked in showDetails?

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted

answered 2021-02-17 12:29:30 +0800

cor3000 gravatar image cor3000
5673 2 7
ZK Team

updated 2021-02-17 12:30:17 +0800

you can pass parameters into @commands using @BindingParam, instead of just the ID it's often more useful to just pass the original each object (no specific ID needed in the first place) ... below an example doing both, just pick the one you prefer/need:


<row id="${each.id}" 
     onClick="@command('showDetails', id=each.id, myobj=each)" >

command handler:

public void showDetails(@BindingParam("id") String id, 
                        @BindingParam("myobj") MyClass myObject) {
     System.out.println("click:" + id + " " + myObject);       

If you really want/need the component id or uuid you can access the component via @ContextParam - however that's rarely needed, so I won't confuse you with details now.

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

1 follower



Asked: 2021-02-17 02:51:21 +0800

Seen: 6 times

Last updated: Feb 17

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More