Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checkbox Cell and Selectable Cell Table rows

Tags:

gwt

I have a GWT 2.4 DataGrid associated with a SingleSelectionModel. One of the columns in the grid is a CheckboxCell, but it is not used for selection, but to set a boolean field value for the underlying item type of the row. My problem is that when I click on the checkbox, the row is selected first, then I have to click a second time to set/unset the checkbox. I would prefer that clicking outside of the checkbox does row selection, while clicking inside of the checkbox only sets/unsets the checkbox. Can anyone point me in the right direction on how to do this. I keep coming back to onBrowserEvent, but I'm not sure what to try.

like image 277
Steve J Avatar asked Nov 04 '11 19:11

Steve J


People also ask

How can I get HTML table row data based on checkbox selection in each row?

Inside the GetSelected JavaScript function, first the Html Table is referenced and then all the CheckBoxes inside the Html Table are referenced. Then a loop is executed over the CheckBoxes and if the CheckBox is checked, the values of Cells of the Row are extracted and displayed using JavaScript Alert Message Box.

How do I select a row in a checkbox?

By default, multiple selection is performed using the ctrl or shift key. You can also perform multiple selection by using Checkboxes that are bound to the Grid rows or using the checkbox bound to the header.


1 Answers

There's a couple of approaches you can do, depending on what exactly you want to do it. Here are the two ideas that come to mind:

  • Use a DefaultSelectionEventManager.CheckboxEventTranslator to blacklist the column
  • Intercept it on a cell by cell basis with CellPreviewEvent.Handler and handle it on the DOM level by checking the EventTarget ("click".equals(event.getType())) and then use event.stopPropogation() when the EventTarget is of an input type "checkbox"
like image 195
Lam Chau Avatar answered Oct 29 '22 00:10

Lam Chau