无法将焦点转移到 Shipments 屏幕上的 Shipment Nbr 字段

Not able to shift focus to Shipment Nbr field on Shipments screen

我正在使用内置的 Acumatica 浏览器命令通过按功能键插入新的货运记录。函数 Key 触发带有 px.searchFrame(window.top,"main")['px_alls'].ds.executeCommand("Insert"); 的命令 由于某种原因,它触发了插入命令,但它不会将焦点转移到 Shipment Nbr 输入字段。此外,如果您尝试使用 var field=px_alls["edShipmentNbr"]; field.focus(); 手动移动焦点,这也不起作用。我已经能够将焦点转移到其他字段,所以我知道代码是正确的,但我无法弄清楚为什么不能将焦点转移到 Shipment Nbr 输入。关于还可以做什么的任何想法?它也不只是 Insert 命令。调用应该转移焦点的取消命令也不起作用。

奇怪的是按Ctrl+Insert可以调用Insert命令,而且完美无缺

我编写了一些代码,将焦点转移到发货日期字段,然后向后跳 5 次,这正确地模拟了插入命令应该执行的操作,但它只能间歇性地在客户端计算机上运行。

谢谢

如果您在 JavaScript 中执行对服务器的回调,回调 return 可能会在完成执行后将焦点设置到另一个字段。您的 focus() 语句有效,但回调 return 在您之后的不同控件上执行另一个 focus()。

挂钩 Ajax 回调允许您将 focus() 语句放在 Acumatica 框架 focus() 之后:

window.addEventListener('load', function () { px_callback.addHandler(ActionCallback); });

function ActionCallback(callbackContext) {
   px_alls["edShipmentNbr"].focus();
};

Acumatica 框架通过 PXButtonAttribute 中定义的以下属性为键盘快捷键提供内置支持:

  • ShortcutShift = true/false : 确定是否存在 Shift 键
  • ShortcutCtrl = true/false : 确定控制键存在
  • ShortcutChar = ‘x’ : 确定快捷字符

下面是当用户按下 F2 时插入新 Shipment 的示例。由于下面的代码片段利用了框架的功能,通过按 F2 用户执行 Insert 命令从 SOShipmentEntry BLC 而不是模拟按钮点击 JavaScript。这种方法保证所有嵌入 Insert 命令的逻辑,包括将焦点设置到 Shipment Nbr 输入,都得到正确执行。

public class SOShipmentEntryExt : PXGraphExtension<SOShipmentEntry>
{
    public class PXInsertShortCut<TNode> : PXInsert<TNode> 
        where TNode : class, IBqlTable, new()
    {
        public PXInsertShortCut(PXGraph graph, string name)
        : base(graph, name)
        {
        }
        public PXInsertShortCut(PXGraph graph, Delegate handler)
            : base(graph, handler)
        {
        }
        [PXUIField(DisplayName = ActionsMessages.Insert, MapEnableRights = PXCacheRights.Insert, MapViewRights = PXCacheRights.Insert)]
        [PXInsertButton(ShortcutChar = (char)113)]
        protected override IEnumerable Handler(PXAdapter adapter)
        {
            return base.Handler(adapter);
        }
    }

    public PXInsertShortCut<SOShipment> Insert;
}