覆盖 CRM 网格中双击事件调用的标准方法。
CRM 2011 中存在以下情况: 我的目标是在一个网格中显示多个实体。因此,我们创建了一个链接到真实实体的包装实体(包装实体到实体 A、B、C)。当创建 A、B 或 C 中的项目时,插件也会创建包装实体项目。 像这样,我可以有一个网格,“混合”所有实体,而实际上只显示包装实体的项目。
但是当然,如果我双击或右键单击 ->在这个网格中打开,我不想打开包装实体项目,我直接想打开例如实体A项目的窗口。顺便说一句,功能区按钮没问题。
到目前为止,我遵循了两条路线:
a)链接替换:加载网格后,我浏览了 DOM,并将 oid、otype 和 otypename 替换为(真实)目标项(实体 A、B 或 C)的值。这个想法有两个缺点:首先是何时执行替换例程(仅在加载时是不够的,因为稍后可以进行排序、过滤或翻转页面)。第二个也是人的问题是功能区按钮。我想删除包装实体项目而不是其背后的发票。当我替换所有这些 ID 时,事情变得很混乱。我必须用自定义按钮替换所有按钮。
b) 方法/事件替换:仅替换调用项目详细信息窗口的事件会很优雅。不幸的是,我还不知道这些事件是如何在 CRM 中实现的,我希望取消附加一个事件并用我的事件替换它,但这似乎是一个隐藏的秘密。 CRMWeb_static_grid\AppGrid_DefaultData.htc 有 dblclick-event,但我不明白这是否是我正在寻找的事件以及如何取消附加。
有没有人尝试过替换 crm 网格中的事件处理程序或知道它是如何工作的?
希望我的意思很清楚...
非常感谢您的任何想法。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
界面中事件的处理方式与 IE 处理所有 javascript 事件(请参阅SO问题我应该直接分配 JavaScript 事件只是为了统一代码吗? 仅举一个例子)。
覆盖默认双击操作的功能可能如下启动:
编辑:根据您的评论,您将在此处对 DOM 进行一些非常严格的自定义。每当网格刷新时,您都必须更改网格中每一行的
dblclick
事件,因为右键单击事件基于该行的dblclick
> 事件。因此,您必须找到网格,并将refresh
事件附加到网格,该网格将dblclick
事件附加到任何找到的行。要获取网格的 id 以及任何行的潜在 id,您可以使用 IE 的 F12 开发人员工具来浏览/搜索 HTML。
Events in the interface are handled the same way IE handles all javascript 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:
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'sdblclick
event. So you'd have to find the grid and also attach arefresh
event to the grid that attaches adblclick
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.
您可以通过连接 A 到 B 和 A 到 C 来显示此数据吗?这三个实体之间有何关系? A到B和A到C? A到B到C?
我问这个问题是因为您应该能够使用视图提供的标准连接功能来实现您的目标,并完全避免这种覆盖业务。如果您必须为此视图在实体之间设置一些关系,那么它可能比包装实体更好。
(我更愿意将其添加为评论......我认为我没有足够的声誉)
Can you display this data by joining A to B and A to C? How are these three entities related? A to B and A to C? A to B to C?
I ask because you should be able to achieve your goal with the standard join functionality provided by Views and avoid this override business altogether. If you have to setup some relationships between the entities just for this view it is probably preferred to a wrapper entity.
(I would prefer to add this as a comment... I dont think I have enough reputation)