12.04.2009, 16:05 | #1 |
Участник
|
mscrm4ever: CRM 4.0 Many 2 Many IFrame Viewer
Источник: http://mscrm4ever.blogspot.com/2009/...me-viewer.html
============== I’ve seen many posts about displaying a many 2 many grid inside an iframe so I didn’t post about it my self until now. One of the disadvantages of using such customization is that it does not follow ms initial execution path which breaks some of the functionality. In our case after you select an existing item the grid does not refresh / reflect your selection until you push the refresh button your self. I wrote a small utility class that solves that problem. It also takes care of the iframe padding. Basically a many to many iframe looks like this: areas.aspx?oId={ObjectId}&oType={ObjectTypeCode}&security=852023&roleOrd=1&tabSet=area{relationship name} The viewer accepts the RoleOrder and Relationship Name (TabsetId) and constructs the iframe for you. Add the code in the entity onload event and Enjoy… function OnCrmPageLoad() { /* Create a ne N2NViewer and give it the IFRAME (container) id */ var n2nViewer = new N2NViewer('IFRAME_account_association'); /* Set the role order - use iedevtoolber for exact parameters */ n2nViewer.RoleOrder = 1; /* assing the relationship name (without the "area" word) */ n2nViewer.TabsetId = "gi_account_account"; /* Do the trick... */ n2nViewer.Load(); } function N2NViewer(iframeId) { if (!document.all[iframeId]) { alert(iframeId + " is missing!"); return; } var viewer = this; var _locAssocObj = null; viewer.IFRAME = document.all[iframeId]; viewer.RoleOrder; viewer.TabsetId; viewer.Load = function() { /* Construct a valid N2N IFRAME url */ viewer.IFRAME.src = "areas.aspx?oId=" + crmForm.ObjectId + "&oType=" + crmForm.ObjectTypeCode + "&security=" + crmFormSubmit.crmFormSubmitSecurity.value + "&roleOrd=" + viewer.RoleOrder + "&tabSet=area" + viewer.TabsetId; viewer.IFRAME.onreadystatechange = viewer.StateChanged; } viewer.StateChanged = function() { if (viewer.IFRAME.readyState != 'complete') { return; } var iframeDoc = viewer.IFRAME.contentWindow.document; /* Reomve scrolling space */ iframeDoc.body.scroll = "no"; /* Remove crmGrid Default padding */ iframeDoc.body.childNodes[0].rows[0].cells[0].style.padding = 0; /* Save MS locAssocObj */ _locAssocObj = locAssocObj; /* Override MS locAssocObj */ locAssocObj = viewer.locAssocObj; } viewer.locAssocObj = function(iType , sSubType, sAssociationName, iRoleOrdinal) { /* Open the Dialog */ _locAssocObj(iType , sSubType, sAssociationName, iRoleOrdinal); /* Refresh only if our iframe contains the correnct tabset name */ if (sAssociationName == viewer.TabsetId) { viewer.IFRAME.contentWindow.document.all.crmGrid.Refresh(); } } } //Entry Point OnCrmPageLoad(); Источник: http://mscrm4ever.blogspot.com/2009/...me-viewer.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
|