覆盖CRM网格中双击事件调用的标准方法。 [英] Override standard method called by double click event in CRM grid.

查看:176
本文介绍了覆盖CRM网格中双击事件调用的标准方法。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CRM 2011中的以下情况:我的目标是在一个网格中显示多个实体。因此,我们创建了一个连接到实体的包装实体(包装实体到实体A,B,C)。当创建A,B或C中的项目时,插件也创建包装器实体项目。
像这样我可以有一个网格,混合所有的实体,而实际上只显示包装实体的项目。但是,当然,如果我在这个网格中双击或右击 - >打开,我不想打开包装器实体项目,我直接要打开例如的窗口实体A项。功能按钮没有问题btw。



我按照两条路线到目前为止:



a)链接替换:加载网格后,我经历了DOM,并用(实体)目标项(实体A,B或C)的值替换oid,otype和otypename。这个想法有两个缺点:第一次执行替换程序时(只有在加载不足以进行排序,过滤或翻页后)。第二和人的问题是丝带按钮。我想删除包装器实体项目,而不是后面的发票。当我更换所有这些ID时,事情会变得困惑。我必须通过自定义按钮来替换所有的按钮。 b)b)方法/事件替换:只要替换调用项目详细信息窗口的事件就会很优雅。不幸的是,我还没有弄清楚事件如何在CRM中实现,我希望能够解除事件,并将其替换为我的,但这似乎是一个隐藏的秘密。 CRMWeb_static_grid\AppGrid_DefaultData.htc具有dblclick事件,但是我不明白这是否是我正在寻找的内容,以及如何卸载。



有没有人曾试图替换crm网格中的一个事件处理程序,或者想到如何工作?



希望很清楚我的意思...



非常感谢任何想法。

解决方案

界面中的事件处理相同IE处理所有 JavaScript 事件的问题(请参阅SO问题我应该直接分配JavaScript事件只是为了统一代码?只是一个例子)。



覆盖默认双击操作的功能启动如下:

  function Load(){
var grid = document。的getElementById( myGridName);
grid.ondblclick = DoubleClickAction;
}

函数DoubleClickAction(){
var id,url;
//获取您双击的行中的实体的ID
id = GetId();

//生成实体窗体url
url = GetUrl();

//打开记录窗口
OpenRecordWindow(url);
}

函数OpenRecordWindow(url){
var url;

if(Xrm.Page.context.isOutlookClient()){
openStdWin(url,您的标题,width = 1024,height = 768,status = 1);
}
else {
window.open(url);
}

}






编辑:根据您的意见,您将在DOM中进行非常严格的DOM定制。每当网格刷新时,您必须更改网格中每行的 dblclick 事件,因为右键单击事件基于行的 dblclick 事件。因此,您必须找到网格,并将刷新事件附加到将 dblclick 事件附加到的网格任何找到的行。



要获取网格的ID和任何行的潜在ID,您可以使用IE的F12开发人员工具浏览/搜索HTML。


Following situation in CRM 2011: My goal is to show several entities in one grid. Therefore we made a wrapper entity which links to the real entity (wrapper entity to entity A, B, C). When an item in A, B or C is created, also an wrapper entity item is created by a plugin. Like this I can have a grid, "mixing" all the entities, while in fact only show the items of the wrapper entity.

But of course, if I do a double click or right click -> open in this grid, I don't want to open the wrapper entity item, I directly want to open the window of e.g. entity A item. Ribbon Button is no problem btw.

I followed two routes so far:

a) Link replacement: After the grid is loaded I went through the DOM and replaced the oid, otype and otypename with the values of the (real) target item (entity A, B or C). This idea has a two downsides: first when to execute the replacement routine (only on load is not enough as its possible to sort, filter or flip pages later). Second and man problem are the ribbon buttons. I want to delete the wrapper entity items and not the invoice behind it. Things get confused when I replace all those IDs. I would have to replace all the buttons by custom buttons.

b) Method/Event replacement: it would be elegant to just replace the event where the item detail window is called. Unfortunately I didn't figure out yet how the events are implemented in CRM, I was hoping to unattach an event and replace it by mine, but this seems to be a hidden secret. CRMWeb_static_grid\AppGrid_DefaultData.htc has the dblclick-event, but I don't understand if this is the one I'm looking for and how to unattach.

Has anyone ever tried to replace an event handler in a crm grid or got an idea how it might work?

Hope it's clear what I mean...

Thank you very much for any idea.

解决方案

Events in the interface are handled the same way IE handles all events (see the SO question Should i assign JavaScript events directly just to unify code? for just one example).

A functionality for overriding the default doubleclick action might start as follows:

function Load() {
    var grid = document.getElementById("myGridName");
    grid.ondblclick = DoubleClickAction;
}

function DoubleClickAction() {
    var id, url;
    //get the id of the entity in the row you double clicked
    id = GetId();

    //generate the entity form url
    url = GetUrl();

    //open the record window
    OpenRecordWindow(url);
}

function OpenRecordWindow(url) {
    var url;

    if (Xrm.Page.context.isOutlookClient()) {
        openStdWin(url, "Your Title", "width=1024,height=768,status=1");
    }
    else {
        window.open(url);
    }

}


Edit: Based on your comments, you're getting into some pretty serious customization of the DOM here. You'd have to change the dblclick event for each row in the grid whenever the grid refreshes since the right click event is based on the row's dblclick event. So you'd have to find the grid and also attach a refresh event to the grid that attaches a dblclick event to any found rows.

To get the id of the grid, and the potential ids of any rows, you can use IE's F12 developer tools to browse/search through the HTML.

这篇关于覆盖CRM网格中双击事件调用的标准方法。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆