PDA

View Full Version : CheckBoxListView



infips00
17 Oct 2009, 1:54 AM
Hi,

I need to use the widget CheckBoxListView as the examples of Ext GWT

http://www.extjs.com/examples/explorer.html#checkboxlistview

I need to detect when the checkbox is clicked. I added a listener to the SelectionModel as following:


final CheckBoxListView<BeanModel> view = new CheckBoxListView<BeanModel>();

view.getSelectionModel().addListener(Events.SelectionChange,
new Listener<SelectionChangedEvent<BeanModel>>() {

public void handleEvent(SelectionChangedEvent<BeanModel> be) {
panel.setHeading("CheckBox ListView (" + be.getSelection().size()
+ " items selected)");
}

});


My problema is that this listener only works when you click in anohter item of the list, not when you click in the checkbox. I've tried with CheckBoxChange and CheckBoxChanged events, but it doesn't work.

Could you help me??? It's very important for me.

Thanks in advance.

sven
17 Oct 2009, 2:06 AM
The selectionchange is not directly linked to the click on a checkbox. Assign an OnClick event to the checkboxlistview and if the target is a checkbox, do your action.

Please read the bugforum guidelines before posting in that forum. I moved it to the help forum now.

infips00
17 Oct 2009, 2:18 AM
Hi Sven.

Thanks for your reply. It's almost the first time I write in this forum.

Is this way correct to add a event to the checkboxlitview?


btn.addListener(Event.ONCLICK, new Listener<ButtonEvent>() {
public void handleEvent(ButtonEvent be) {
// ButtonEvent is a DomEvent subclass

// retrieve the event target
Element target = be.getTarget();

// get the mouse location
Point point = be.getXY();

// is the control key pressed?
boolean control = be.isControlKey();

// cancel event bubbling
be.cancelBubble();
}
});

mariusz.pala
18 Oct 2009, 10:15 AM
Your code could work if the Change event would be fired as requested ;) http://www.extjs.com/forum/showthread.php?t=82781

sven
18 Oct 2009, 10:17 AM
Your code could work if the Change event would be fired as requested ;) http://www.extjs.com/forum/showthread.php?t=82781

Sorry, but this is not correct. A checkboxlistview is never firing a Change event.

ITB
6 Nov 2009, 8:03 AM
Hi,

Can somebody tell me how can I check if the target is a checkbox ?

I'm using getTarget() method which return Element. After that I'm trying to check if is checkbox.


Many Thanks

ibtissam.haidoudi
4 Jan 2012, 7:06 AM
Hi,

I have the same problem at the CheckBoxListView, when i need to detect when i checked the checkBox at the list.

Plz help me


Hi,

I need to use the widget CheckBoxListView as the examples of Ext GWT

http://www.extjs.com/examples/explorer.html#checkboxlistview

I need to detect when the checkbox is clicked. I added a listener to the SelectionModel as following:


final CheckBoxListView<BeanModel> view = new CheckBoxListView<BeanModel>();

view.getSelectionModel().addListener(Events.SelectionChange,
new Listener<SelectionChangedEvent<BeanModel>>() {

public void handleEvent(SelectionChangedEvent<BeanModel> be) {
panel.setHeading("CheckBox ListView (" + be.getSelection().size()
+ " items selected)");
}

});


My problema is that this listener only works when you click in anohter item of the list, not when you click in the checkbox. I've tried with CheckBoxChange and CheckBoxChanged events, but it doesn't work.

Could you help me??? It's very important for me.

Thanks in advance.

Ersmarker
5 Jan 2012, 1:24 AM
This code detects if a checkbox is clicked in the CheckboxlistView.



view.addListener(Events.OnClick, new Listener() {
public void handleEvent(BaseEvent be) {
if (((DomEvent)be).getTarget(".x-view-item-checkbox", 2) != null) {
// A checkbox is clicked
}
}
});

ibtissam.haidoudi
5 Jan 2012, 1:51 AM
I detect now the click at the checkBox :)


This code detects if a checkbox is clicked in the CheckboxlistView.



view.addListener(Events.OnClick, new Listener() {
public void handleEvent(BaseEvent be) {
if (((DomEvent)be).getTarget(".x-view-item-checkbox", 2) != null) {
// A checkbox is clicked
}
}
});