In my application, I have a table displayed and a button window along the top:
<buttonsPanel height="30px">
<button id="btnAddPin" action="tblPins.create" caption="Create Response" icon="icons/create.png" responsive="true"/>
<button id="btnSavePin" action="tblPins.Save" caption="Save Responses" icon="icons/save.png" responsive="true"/>
<button id="btnRemovePin" action="tblPins.remove" caption="Delete Response" icon="icons/remove.png" responsive="true"/>
</buttonsPanel>
<table id="tblPins" editable="true" height="400px" width="200px">
<actions>
<action id="create" invoke="onAddPin" shortcut="CTRL-ARROW_DOWN"/>
<action id="Save" invoke="onSavePin"/>
<action id="remove"/>
</actions>
<columns>
<column id="pin" editable="true"/>
</columns>
<rows datasource="updtransDs"/>
</table>
The “Create Response” button calls this action:
@Inject
private CollectionDatasource<Batchhdr, Long> batchhdrsDs;
@Inject
private CollectionDatasource<Updtrans, Long> updtransDs;
@Inject
private OptionsGroup paymentOptionsGroup;
@Named("tblPins")
private Table<Updtrans> pinTable;
public void onAddPin() {
if (batchhdrsDs.getItem() == null) {
showNotification("Please open an existing batch or create a new batch first", NotificationType.ERROR);
return;
}
if (paymentOptionsGroup.getValue() == null) {
showNotification("Please set a default payment type first", NotificationType.ERROR);
return;
}
Updtrans updtrans = metadata.create(Updtrans.class);
updtrans.setTraynumber(batchhdrsDs.getItem());
updtrans.setPurchdate(batchhdrsDs.getItem().getBatchdate());
updtrans.setPaymentcode(paymentOptionsGroup.getValue());
updtrans.setAmount(BigDecimal.ZERO);
updtransDs.addItem(updtrans);
pinTable.setSelected(updtrans);
pinTable.scrollTo(updtrans);
pinTable.requestFocus(updtrans,"pin");
}
-
The pinTable.requestFocus(updtrans,“pin”) call does not work. When I click the “Create Response” button, the focus stays there and does not move to the “pin” column of the newly added uptrans record.
-
There is a fieldgroup for updtransDs also displayed on the screen. I have a custom Pickerfield in the table generated with addGeneratedColumn. That Pickerfield has a custom lookup action. When that action completes, I would like to move focus to a field inside the fieldgroup. I tried:
pinTable.requestFocus(updtrans, "amount");
but this does not work. Is it because the field is in a fieldgroup and not in the table itself? How can I move focus to a particular field in a fieldgroup - or anywhere on the page - at the end of my action?