-
10 Feb 2009 4:54 AM #1
EditGrid and Checkbox
EditGrid and Checkbox
It is easy to add a checkbox to an Editgrid and showing data goes just fne. However, I have not been able to find out how to grab any edit events from the box. What I have done is this:
When getting data for the grid I have done as follows:Code:ccolumn = new CheckColumnConfig("isIt", "IsIt?",35); // create a new checkbox CheckBox cb = new CheckBox(); cb.setAutoValidate(true); // set the column editor ccolumn.setEditor(new CellEditor(cb )); // add the column configs.add(ccolumn); //.. etc cm = new ColumnModel(configs); cp = new ContentPanel(); //.. Listener CbListener = new Listener(){ public void handleEvent(BaseEvent be) { Window.alert("foo from the grid"); } };
The "ValidateEdit" is just an example - I have tried BeforeEdit and AfterEdit as well. The event fires just fine with a TextField but not with the checkbox field.Code:grid.addListener(Events.ValidateEdit,CbListener); grid.addPlugin(ccolumn); // add the grid to the contentpanel cp.add(grid);
What am I doing wrong here? Am I totally lost with the editors? Are there any special things to take into account when using other than TextField cell editors?
Markku
-
10 Feb 2009 7:11 AM #2
have you tried "Events.Change" since that event is fired when a checkbox state is changed.
-
10 Feb 2009 8:22 AM #3
Yes, actually after trying all imaginable events I finally understood that CellEditor cb editor actually does not even replace the icon displayed. For some reason unknown to me I cannot even set the CellEditor for the CheckBox column. A TextField editor in the previous cell works just fine.
And I simply cannot see any of the events fire. No idea why. This weird behaviour probably makes me revert part of the project back to Flex. I have not yet seen any working example of an EditGrid checkbox, the examples do not have one and nothing found in the mighty Internet.
I am very grateful if anybody who has done this before is willing to share the secret...
Markku
-
10 Feb 2009 8:26 AM #4
You need to override onMouseDown of CheckColumnConfig. CheckColumnConfig doent use a real cell editor.
-
10 Feb 2009 10:20 AM #5
-
10 Feb 2009 10:27 AM #6
There is no mess in the EditorGrid. It is just that CheckColumnConfig isnt using any CellEditor.
-
10 Feb 2009 10:33 AM #7
Sorry, I what I meant was that I really need to create an special component that incapsulates EditorGrid and a few other components - just to save time and make the code more concise.
For me any framework is a mess before I have my own abstraction level ready - and it is looking better already


Reply With Quote
