Browse Source

Clarification for GridContextClickEvent

tags/8.1.0.rc2
Ilia Motornyi 7 years ago
parent
commit
6e6fb1a474

+ 9
- 1
documentation/components/components-grid.asciidoc View File

object contains various information, most importantly the ID of the clicked row object contains various information, most importantly the ID of the clicked row
and column. and column.



[source, java] [source, java]
---- ----
grid.addCellClickListener(event -> grid.addCellClickListener(event ->
indicator style by default, while the row does not. You can enable row focus, as indicator style by default, while the row does not. You can enable row focus, as
well as disable cell focus, in a custom theme. See <<components.grid.css>>. well as disable cell focus, in a custom theme. See <<components.grid.css>>.


[[components.grid.right.clicks]]
=== Right-clicks
Right-clicks are supported similar way via `addContextClickListener()` method


[source, java]
----
grid.addContextClickListener(event -> Notification.show(
((GridContextClickEvent<Person>)event).getItem() + " Clicked")
);
----


[[components.grid.columns]] [[components.grid.columns]]
== Configuring Columns == Configuring Columns

+ 26
- 0
server/src/main/java/com/vaadin/ui/Grid.java View File

/** /**
* ContextClickEvent for the Grid Component. * ContextClickEvent for the Grid Component.
* *
* <p>
* Usage:
* <pre>
* grid.addContextClickListener(event -&gt; Notification.show(
* ((GridContextClickEvent&lt;Person&gt;)event).getItem() + " Clicked")
* );
* </pre>
* @param <T> * @param <T>
* the grid bean type * the grid bean type
*/ */
* @param listener * @param listener
* the item click listener, not null * the item click listener, not null
* @return a registration for the listener * @return a registration for the listener
* @see #addContextClickListener
*/ */
public Registration addItemClickListener( public Registration addItemClickListener(
ItemClickListener<? super T> listener) { ItemClickListener<? super T> listener) {
listener, ITEM_CLICK_METHOD); listener, ITEM_CLICK_METHOD);
} }


/**
* Adds a context click listener that gets notified when a context click
* happens.
*
* @param listener
* the context click listener to add, not null
* actual event provided to the listener is {@link GridContextClickEvent}
* @return a registration object for removing the listener
*
* @since 8.1
* @see #addItemClickListener
* @see Registration
*/
@Override
public Registration addContextClickListener(ContextClickEvent.ContextClickListener listener) {
return super.addContextClickListener(listener);
}

/** /**
* Registers a new column visibility change listener. * Registers a new column visibility change listener.
* *

Loading…
Cancel
Save