PDA

View Full Version : Editor Grid With Row editor



ahmed_hassan
13 Jul 2010, 7:29 AM
Hi,
i have a big problem
i have a grid that contains 8 columns three of them are visible and the others are invisible
i used Editor Grid so that if the user want to edit in the three visible fields can do it in the grid directly and i added a fourth column that contain a button when the user click on it it will open a row editor with all the 8 columns to edit in the invisible columns.
it works correctly when i edit in the grid directly once i edit in it using the row editor i can't edit in it again using the grid itself the only way then by using the row editor

Any help please ??

Thanks in advance

sven
13 Jul 2010, 7:30 AM
You cannot use the default roweditor. It wont work with an EditorGrid. It only works with a normal grid that has no editing.

ahmed_hassan
13 Jul 2010, 10:17 PM
Hi

Thank you for your interest and quick reply;
Could you specify to me why won't it work, if this is a valid question?
and if it is doable could you help me by tips how can i do it ?

Thanks in advance

pef
1 Nov 2010, 2:37 AM
Hi,

I revive this post because I'd have loved finding it before solving my problem, so let me add some information here, for others to find the answer more easily.

So, I was also using a RowEditor with an EditorGrid (actually, this wasn't intentional : I forgot to turn it back into a Grid after trying something out, but anyway).

My goal was to hook on the save button on the RowEditor.
So I added a listener on the AfterEdit RowEditorEvent.
The problem : the event wasn't fired when clicking the save button. Nevertheless, the row editor was correctly hidding.

The reason is that when clicking the save button :
1) the CellEditor field 'completeEdit' method gets called : it fires Complete
2) the EditorGrid's EditorSupport 'onEditComplete' method gets called : it sets the model's value through its Record
...
3) only then, the RowEditor save button SelectionListener gets called, then the RowEditor 'stopEditing' method, which :
4) compares the field value against the model : but at this point, the model has already been updated (-> at 2)
5) if hasChange had been true, it would have set the model's value through its Record
6) if hasChange had been true, it would then have fired the AfterEdit event

The solution was to realize that I should use a simple Grid, so that steps 5 and 6 can happen instead of 1 and 2.

Finally, a suggestion : could it be made clearer in the documentation ?
Currently, the RowEditor doc states "This RowEditor should be used as a plugin to Grid". could you add " (but not to EditorGrid)" ?

ashly.jos@gmail.com
6 Apr 2011, 1:33 AM
Hi,

Found this post, but I'm struck in the initial stage. I need to add a button to the last column and perform some tasks on the row when someone clicks it.

How can I do that? How do I add a button? I can't find any CellEditor constructor that accepts a button.

Thanks in advance,
-ash

ashly.jos@gmail.com
6 Apr 2011, 8:43 AM
Hi All,

I have managed to do this own my own.... Now, I have moved into a different problem.

I have combo box in one column and button in another. Depending on the value selected in the combo box, I need to make the button enabled/disabled. How do I do that?




final SimpleComboBox<String> combo = new SimpleComboBox<String>();
combo.setForceSelection(true);
combo.setTriggerAction(TriggerAction.ALL);
combo.add("role 1");
combo.add("role 2");
combo.add("role 3");

combo.addSelectionChangedListener(new SelectionChangedListener<SimpleComboValue<String>>() {

@Override
public void selectionChanged(SelectionChangedEvent<SimpleComboValue<String>> se) {
Info.display("Info", "Selection changed to " + (String) se.getSelectedItem().get("value"));
}
});

CellEditor editor = new CellEditor(combo) {
@Override
public Object preProcessValue(Object value) {
if (value == null) {
return value;
}
return combo.findModel(value.toString());
}

@Override
public Object postProcessValue(Object value) {
if (value == null) {
return value;
}
return ((ModelData) value).get("value");
}
};

column = new ColumnConfig();
column.setId("role");
column.setHeader("Role");
column.setWidth(80);
column.setEditor(editor);
configs.add(column);



/*************************************************************************/
GridCellRenderer buttonRenderer = new GridCellRenderer() {

public Object render(final ModelData model, String property, ColumnData config, final int rowIndex, int colIndex, ListStore store, Grid grid) {
Button b = new Button("Countries", new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
if(model instanceof UserDTO){
Info.display("infor", "cooooll Button clicked: " + ((UserDTO) model).getFirstName());
} else {
Info.display("infor", "Button clicked: " + rowIndex);
}

}
});
b.setWidth(grid.getColumnModel().getColumnWidth(colIndex) - 10);
b.setToolTip("Click for more information");
if(model instanceof UserDTO){
UserDTO user = (UserDTO) model;
if(user != null && "Marketer".equalsIgnoreCase(user.getRole())){
b.setEnabled(false);
}
}

return b;
}

};

/******************************************************/
column = new ColumnConfig();
column.setId("countries");
column.setHeader("Countries");
column.setWidth(100);
column.setRenderer(buttonRenderer);
configs.add(column);


thanks,
-ash