PDA

View Full Version : EditorGrid with different CellEditor on different row



skcurry
29 Feb 2012, 6:25 PM
Hi all,

I finding a solution to read dynamic data, and use EditorGrid with different CellEditor on different row at same column for the data. Can I do that? Any ideas?

smiletolead
7 Mar 2012, 11:42 PM
I see a way to set to different editors for different rows. Here is the example that uses combo box for the one row and normal editor for the next row for the same column.



grid.addListener(Events.BeforeEdit, new Listener<GridEvent<Plant>>() {
public void handleEvent(GridEvent<Plant> be) {
// be.getColIndex()
int rowIndex = be.getRowIndex();
int colIndex = be.getColIndex();
if (colIndex == 1) {
if (rowIndex % 2 == 0) {
grid.getColumnModel().getColumn(colIndex).setEditor(editor);
} else {
grid.getColumnModel().getColumn(colIndex).setEditor(textEditor);
}
}


};
});

Although it seems to work fine, I am not sure of it has any consequences.