简体   繁体   English

防止在动态 365 中双击打开记录

[英]preventing opening of record on double click in dynamics 365

I have set up a Queue for our Abstract entity.我已经为我们的抽象实体设置了一个队列。 I am trying to prevent the double click opening of the record.我试图阻止双击打开记录。 I have set up a handler for the event, and call.stopPropagation() and.preventDefault() on the event object, and it continues to open up the window.我已经为事件设置了一个处理程序,并在事件 object 上调用了.stopPropagation() 和.preventDefault(),它继续打开了 window。

Not sure if I'm missing something obvious or what.. here's my code:不确定我是否遗漏了一些明显的东西或什么......这是我的代码:

function attachDoubleClick() {
    var grid = document.getElementById("gridBodyTable");
    if (grid == null) {
        setTimeout(function () { attachDoubleClick(); }, 2000); //if the grid hasn’t loaded run this again
        return;
    }

    function handler(e) {
        var abstractId = document.getElementsByClassName("ms-crm-List-SelectedRow").item().getAttribute("oid").replace("}", "").replace("{","");
        XrmSvcToolkit.retrieve({
            entityName: "prod_abstract",
            id: abstractId,
            select: ["prod_abstractstatus"],
            async: false,
            successCallback: function (result) {
                if (result.prod_abstractstatus.Value != 108410000) {
                    alert("This abstract is already being worked on or is completed.");
                    e.stopPropagation();
                    e.preventDefault();
                    console.log(e);
                    return;
                }
            },
            errorCallback: function (error) {
                console.log(error);
            }
        });
    }
    grid.ondblclick = handler;
}


The issue was I needed to addEventListener with a 3rd parameter of true.问题是我需要添加第三个参数为 true 的事件监听器。 (this is the useCapture parameter.) End code looked like this: (这是 useCapture 参数。)结束代码如下所示:

function attachDoubleClick() {
    var grid = document.getElementById("gridBodyTable");
    if (grid == null) {
        setTimeout(function () { attachDoubleClick(); }, 2000); //if the grid hasn’t loaded run this again
        return;
    }
    grid.addEventListener("dblclick", handler, true);
}


function handler(e) {
    console.log(e);
    var abstractId = document.getElementsByClassName("ms-crm-List-SelectedRow").item().getAttribute("oid").replace("}", "").replace("{", "");
    XrmSvcToolkit.retrieve({
        entityName: "prod_abstract",
        id: abstractId,
        select: ["prod_abstractstatus"],
        async: false,
        successCallback: function (result) {
            if (result.prod_abstractstatus.Value != 108410000) {
                alert("This abstract is already being worked on or is completed.");
                e.stopPropagation();
                e.preventDefault();
                return;
            }
        },
        errorCallback: function (error) {
            console.log(error);
        }
    });

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 防止 Apex 按钮双击 - Preventing Apex Button Double click Dynamics CRM 365-如何打开基于相关记录过滤的视图 - Dynamics CRM 365 - How to open view filtered based on related record 停用记录时禁用 Dynamics 365 中的确认弹出窗口 - Disable confirmation popup in Dynamics 365 when record is deactivated 由工作流创建后重定向到新创建的 Dynamics 365 记录 - Redirecting to newly created Dynamics 365 record after created by workflow 单击按钮时显示进度 Dynamics CRM 365 - show progress when click button Dynamics CRM 365 如何通过 javascript 单击 Dynamics 365 功能区按钮 - How to click Dynamics 365 Ribbon Button via javascript 双击打开文件 electron - Opening files with electron from double click 在 Dynamics 365 XRM Web API 中创建记录时无法设置多选选项字段 - Cannot set multi-select option field when creating record in Dynamics 365 XRM Web API 在 JS-Dynamics 365 中使用“Xrm.WebApi.createRecord”创建实体记录 - Create an Entity Record using "Xrm.WebApi.createRecord" in JS- Dynamics 365 在 Dynamics 365 中,是否可以根据记录的字段值和用户权限筛选关联的视图结果? - In Dynamics 365, is there a way to filter associated view results based on a record's field value and user permissions?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM