I have dialog, wich is have buttons in html and aspx
HTML
<qp-button id="buttonOK" caption="OK" state.bind="buttonOK" dialog-result="Cancel"></qp-button>
<qp-button id="ButtonCancel" caption="Cancel" state.bind="ButtonCancel" dialog-result="Cancel"></qp-button>
and
<px:PXButton ID="ButtonOk" runat="server" Text="OK" CommandSourceID="ds" DialogResult="Cancel" CommandName="buttonOK"></px:PXButton>
<px:PXButton ID="ButtonCancel" runat="server" Text="Cancel" CommandSourceID="ds" DialogResult="Cancel" CommandName="ButtonCancel"></px:PXButton>
also i have barcode field and added in aspx next code for Auto button press
function Barcode_Initialize(ctrl) {
ctrl.element.addEventListener('keydown', function (e) {
if (e.keyCode === 13) { //Enter key
var barcode = px_alls['edBarcode'];
var buttonOk = px_alls['ButtonOk'];
e.preventDefault();
e.stopPropagation();
if (barcode.value != null) {
waitBarcode(500, barcode, buttonOk);
}
}
});
};
function waitBarcode(ms, barcode, buttonOk) {
setTimeout(() => {
if (barcode.value != null) {
waitBarcode(ms, barcode, buttonOk);
}
else if (barcode.errorCss == undefined) {
buttonOk.elemButton.click();
}
}, ms);
}
and in TS file
@handleEvent(CustomEventType.ValueChanged, { view: "MyFilter", field: "Barcode", order: 1 })
onMyFilterBarcodeChange(args: ValueChangedHandlerArgs) {
if (this.isProcessingBarcode) {
return;
}
const newVal = args?.newValue;
const oldVal = args?.oldValue;
if (!newVal || newVal.toString().trim() === "") {
return;
}
this.isProcessingBarcode = true;
this.screenService.executeCommand("ScanBarcode")
.finally(() => {
this.isProcessingBarcode = false;
setTimeout(() => {
if (!this.screenService.hasFieldsErrors()) {
this.screenService.executeCommand(buttonOK");
}
}, 1000)
});
}
in old ui i next behaviour, when i press ented and everything is OK i press button and dialog closes.
In Modern i tried
this.screenService.executeCommand("buttonOK");
and
this.buttonOK.press()
action works, but dialog dont closes. Maybe someone met this issue, or solved similar. Please help!