PDA

View Full Version : setting focus back to a cell of the editable grid



emmas
23 Aug 2010, 1:06 PM
Hi,
I have a few questions,
all related to editable grid, but I will ask them in separate posts:

On the editable grid, after validating a record (on AfterEdit event for the cell),
how do I set focus back to that cell if it didn't pass validation?

thanks

sven
23 Aug 2010, 1:07 PM
You mean you want to start editing again?

emmas
23 Aug 2010, 1:10 PM
Thanks Sven, yes, if it didn't pass validation, i am displaying pop-up message saying that data is invalid, so need to bring focus to the correct row and cell which contains the invalid data.

sven
23 Aug 2010, 1:16 PM
editorGrid.startEditing(row, cell);

hartwigpl
27 Aug 2010, 12:10 PM
Is it possible to set the focus back to the cell too? Using the startEditing call will put the cell in edit mode, but the user must still select the cell to add/edit text.

emmas
27 Aug 2010, 12:17 PM
it does put the focus back, you have to put startEditing() in right place


msgbox.addCallback(new Listener<MessageBoxEvent>() {
@Override

public void handleEvent(MessageBoxEvent be) {
String dialogResponse = be.getButtonClicked().getItemId();
if (dialogResponse.equals(Dialog.OK)) {
paymentGrid.startEditing(row, col);
}
}
});
msgbox.show();

emmas
27 Aug 2010, 12:22 PM
and you also have to select that row, here is all code for message box




private void displayValidationMessageBox(String displayMsg) {


final BeanModel paymentModel = (BeanModel) paymentStore.getAt(row);


MessageBox msgbox = new MessageBox();


msgbox.setButtons(MessageBox.OK);
msgbox.setIcon(MessageBox.INFO);
msgbox.setMessage(displayMsg);
paymentGrid.getSelectionModel().select(paymentModel, false); // selecting row
msgbox.addCallback(new Listener<MessageBoxEvent>() {
@Override
publicvoid handleEvent(MessageBoxEvent be) {
String dialogResponse = be.getButtonClicked().getItemId();
if (dialogResponse.equals(Dialog.OK)) {
paymentGrid.startEditing(row, col); //set the focus back to the cell
}
}
});
msgbox.show();

}

SenthilMahalingam
13 Jun 2011, 10:31 AM
How do I keep the focus on the non-editable cell ?,editorGrid.startEditing(row, cell) works only in editable cell.