-
22 Aug 2011 9:37 PM #1
CellEditor and CheckBox doesn't get along, workaround?
CellEditor and CheckBox doesn't get along, workaround?
Hi,
I have an EditorGrid that constructed like this.
Basically it's a EditorGrid that have 2 columns, and have different editor field for each one.
First column is a string column and have a TextField as the editor, and second column is a boolean and have a CheckBox as the editor.
Now, the cells that have TextField behave as expected.
However, those which have CheckBox as the editor do not.
Clicking the cell will turn the cell into edit mode and showed the checkbox as expected, but clicking the checkbox will stop the editing and turn the cell back to view mode without toggling the boolean value.
I believe the expected behavior should be for the checkbox to be clickable, toggling the boolean value in the process.
A little debugging revealed that the click on the CheckBox is regarded as OnBlur, which I think should not be the case (please be aware of my minimum experience with GXT though).
Is this a bug? Is there any workaround?
Thanks before.
-
23 Aug 2011 8:49 AM #2
The issue is probably due to the fact that CheckBox changes is value differently than most other fields. In most cases, the change event doesnt occur until blur, but in the case of a checkbox, often people want to have other changes happen in the UI as soon as the CheckBox changes, based on that change event.
This feature can be disabled by calling CheckBox.setFireChangeEventOnSetValue(false). While I haven't tried your code sample, I believe this discrepancy between CheckBox and other Fields might be the root of your issue.
-
3 Sep 2011 7:00 PM #3
Calling CheckBox.setFireChangeEventOnSetValue(false) didn't work.
Do you have any other idea on what other thing we should try doing?
-
1 Dec 2011 8:41 AM #4
Hi,
Does anyone get a solution?
I have the same need : an editorgrid with some columns. One column is render as a checkbox.
The checkbox is only render when I click on the cell : it show the checkbox, so I can check or uncheck.
It is possible to ovewrite the render to display the checkbox "image". But when I do this, when I click on the checkbox, it does not directly check/uncheck it, it displays the cell in edit view (so the real checkbox that I checkuncheck).
What I would like to be possible : display the checkbox (checked or unchecked, depending of the value of the cell), and that the user can directly check/uncheck it. I would like a kind of "always display the edit mode view" for this column.
Note : I would like NOT to use a selection model, etc.Code:ColumnConfig checkboxCol = new ColumnConfig("Selection", "dataKeyOfCheckBox", 60); CheckBox cb = new CheckBox(); cb.setInEditor(true); checkboxCol.setEditor(new CellEditor(cb));
Another general question : is it possible to display an editorgrid in a "edit view mode" always? I mean it does not switch automatically between read/write mode for each cell.
-
8 Dec 2011 2:47 AM #5
Actually, it was quite simple. I used a CheckColumnConfig without CellEditor (not to have the cell switching to edit mode) + set the pluggin.
Preview of some source code lines :
Then I customize some behaviour for my needs ( override getCheckState() and onMouseDown() ).Code:// ... CheckColumnConfig checkboxColumn = new CheckColumnConfig("keyCol", "Title", 60); // ... ColumnModel cm = new ColumnModel(Arrays.asList(myCol1, myCol2, checkboxColumn)); // ... grid.addPlugin(checkboxColumn);


Reply With Quote