【问题标题】:How to create inline dialog in MS CRM 2013如何在 MS CRM 2013 中创建内联对话框
【发布时间】:2014-05-14 11:37:54
【问题描述】:

MS CRM 2013 引入了在系统内打开对话框的新方法。在 2011 版中,查找作为单独的(模态)窗口打开,但在 2013 年,查找在当前页面上作为内联 iframe 打开。

绝对可以通过以下 jQuery 语句实现:

$('body').append("<div id='InlineDialog_Background' class='ms-crm-InlineDialogBackground' tabindex='0' style='position: absolute; width: 100%; height: 100%; top: 0px; background-color: rgb(128, 128, 128); z-index: 1005; opacity: 0.5;'></div>");
$('body').append("<div id='InlineDialog' class='ms-crm-DialogChrome' tabindex='1' style='position: absolute; top: 50%; left: 50%; z-index: 1006; margin-top: -240px; margin-left: -400px; height: 540px; width: 800px;'><iframe id='InlineDialog_Iframe' name='InlineDialog_Iframe' src='custom_url' style='height: 540px; width: 800px; border: 0px;'></iframe><div id='DialogLoadingDiv' style='position: absolute; background-color: white; height: 480px; width: 800px; top: 50%; left: 50%; margin-top: -240px; margin-left: -400px; z-index: 1007; display: none;'><table class='ms-crm-LoadingContainer' style='width:100%;height:100%'><tbody><tr class='ms-crm-LoadingContainer'><td style='vertical-align: middle' align='center'><img id='DialogLoadingDivImg' alt='' src='/_imgs/AdvFind/progress.gif'><br>Loading...</td></tr></tbody></table></div></div>");

但它还需要一些额外的例程才能正确关闭此类对话框。

有没有微软提供的 javascript 方法来打开这样的iframe

【问题讨论】:

    标签: javascript dynamics-crm-2013


    【解决方案1】:

    Here是在此类对话框中显示网络资源的示例。

    在父窗口中:

    var src = <Relative_Url_of_the_Webresource>;
    var DialogOptions = new Xrm.DialogOptions(); 
    DialogOptions.width = 500;
    DialogOptions.height = 400;
    Xrm.Internal.openDialog(src, DialogOptions, null, null, CallbackFunction);
    
    function CallbackFunction(returnValue){ }
    

    另外,您必须在您的网络资源中包含 ClientGlobalContext.js.aspx,例如:

    <script type="text/javascript" src="/webresources/ClientGlobalContext.js.aspx"></script> 
    

    用于将对话框的返回值传递给父窗口:

    Mscrm.Utilities.setReturnValue(result);
    try {
        closeWindow(true); //Close the dialog box
    }
    catch (e) { }
    

    【讨论】:

    • 看起来干净多了!谢谢!
    • 当我像这样打开 WebResource 时,它​​会将“?dType=1”附加到导致内部服务器错误的 URL,因为参数似乎无效 (GET crm2013/Org/WebResources/tv_closeEmail?dType=1500 (Internal Server Error ))。知道如何防止这种情况发生吗?
    • 仅供参考,这适用于在 dialogArguments window.getInlineDialogArguments() 中阅读
    • Michael Barth - 你最终解决了我们现在在 HTTPS 网站上遇到的问题吗?
    • @Andi:是的,实际上我是在再次尝试时才发现的。问题是,您需要像这样“$webresource:new_yourWebResource”(前缀“$webresource:”很重要!)传递 webresource url。然后不会将“dType”参数附加到 URL。
    【解决方案2】:

    当然这是不受支持的,方法也没有记录,但您可以尝试使用以下方法 - http://a33ik.blogspot.com/2014/05/show-your-dialog-in-crm-2013-modal-style.html

    代码如下:

    if (typeof Custom == "undefined") {
        Custom = {
            OpenDialog: function (webresource) {
                var $v_0 = new Mscrm.CrmDialog(Mscrm.CrmUri.create(webresource), window, 370, 370, null);
                $v_0.show();
            },
            __namespace: true
        };
    }
    

    使用示例:

    Custom.OpenDialog("/webresources/new_webresource.htm");
    

    【讨论】:

      【解决方案3】:

      不支持以编程方式打开查找对话框的方式。

      Dynamics CRM 2013 SDK 列出了支持的查找控制方法:

      1. 添加自定义过滤器
      2. 添加自定义视图
      3. getDefaultView
      4. 设置默认视图

      您还可以添加预搜索事件。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-04-11
        • 1970-01-01
        相关资源
        最近更新 更多