AXForum  
Вернуться   AXForum > Microsoft Dynamics CRM > Dynamics CRM: Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 12.03.2009, 07:05   #1  
Blog bot is offline
Blog bot
Участник
 
25,640 / 848 (80) +++++++
Регистрация: 28.10.2006
mscrm4ever: Display Fetch in IFRAME – Part 2
Источник: http://mscrm4ever.blogspot.com/2009/...me-part-2.html
==============



My first post about displaying fetch inside an IFRAME has two disadvantages. The first is that the context of the parent window does not follow to the new entity window when you click on add new record (grid) button. This is might be annoying if you’re counting on the default mapping between the two entities. The second problem is that the grid does not refresh after you add (new button) or remove (delete button) a record. This means you are not able to see the changes unless you press on the grid refresh button your self.


I made piece with the fact that the parent context did not follow through to the child window since I was using advanced find. But the fact that the gird does not refresh automatically came as a surprise since I remember this feature working “AS IS” in v3.0. I guess ms did a few changes to the auto function which searched and refreshed the grid. Thanks to Dave Berry who commented / Posted about this and brought it to my attention.


In order to overcome this issue I added two new properties to the FetchViewer class.


The first parameter is called WithParentContext. This property allows you to decide whether the parent window object id is passed to the child window. I made it a public (as opposed to internal) choice since I figured you can display any type of query inside the FetchViewer including a query that does not reflect a direct parent child relationship.


The second parameter is the EntityCode (ObjectTypeCode) of the entity being fetched. If you want the grid to refresh automatically you must supply this value. This is important since the value is eventually passed to MS original auto function which expects this value.


The rest of the fetch viewer class was not changed and you can read all about it here.



function OnCrmPageLoad()
{
window.fetchAccounts1 = new FetchViewer("IFRAME_test");
fetchAccounts1.WithParentContext = true;
fetchAccounts1.EntityCode = 2;
fetchAccounts1.FetchXml = getFetchXml();
fetchAccounts1.LayoutXml = getLayoutXml();
fetchAccounts1.Entity = "contact";
fetchAccounts1.QueryId = "{00000000-0000-0000-00AA-000000666400}";
fetchAccounts1.RegisterOnTab(0); //IFRAME ON THE THIRD TAB (index eq 2)
}

function getFetchXml()
{
return '';
}

function getLayoutXml()
{
return '';
}

function FetchViewer( iframeId )
{
var Instance = this;
var vDynamicForm;
var m_iframeTab;
var m_iframeDoc;
var m_iframeShowModalDialogFunc = null;
var m_windowAutoFunc = null;

Instance.WithParentContext = false;
Instance.EntityCode = 0;
Instance.Entity = "";
Instance.Iframe = null;
Instance.FetchXml = "";
Instance.QueryId = "";
Instance.LayoutXml = "";

Instance.RegisterOnTab = function( tabIndex )
{
Instance.Iframe = document.getElementById( iframeId );

if( !Instance.Iframe )
{
return alert( "Iframe " + iframeId + " is undefined" );
}

m_iframeDoc = getIframeDocument();
var loadingGifHTML = "";
loadingGifHTML += "";
loadingGifHTML += "";
loadingGifHTML += "";
loadingGifHTML += "Loading View...";
loadingGifHTML += "";
m_iframeDoc.body.innerHTML = loadingGifHTML;

if( parseInt( "0" + tabIndex ) == 0 )
{
Instance.Refresh();
}
else
{
Instance.Iframe.attachEvent( "onreadystatechange" , RefreshOnReadyStateChange );
}
}

function RefreshOnReadyStateChange()
{
if( Instance.Iframe.readyState != 'complete' )
{
return;
}

Instance.Refresh();
}

Instance.Refresh = function()
{
if( !Instance.Iframe )
{
return alert( "Iframe " + iframeId + " is undefined" );
}

m_iframeDoc = getIframeDocument();

Instance.Iframe.detachEvent( "onreadystatechange" , RefreshOnReadyStateChange );

var create = m_iframeDoc.createElement;
var append1 = m_iframeDoc.appendChild;
vDynamicForm = create("");

var append2 = vDynamicForm.appendChild;
append2(create(""));
append2(create(""));
append2(create(""));
append2(create(""));
append2(create(""));
append1( vDynamicForm );

vDynamicForm.action = "/" + ORG_UNIQUE_NAME + "/AdvancedFind/fetchData.aspx";
vDynamicForm.FetchXml.value = Instance.FetchXml;
vDynamicForm.LayoutXml.value = Instance.LayoutXml;
vDynamicForm.EntityName.value = Instance.Entity;
vDynamicForm.DefaultAdvFindViewId.value = Instance.QueryId;
vDynamicForm.ViewType.value = 1039;
vDynamicForm.submit();

Instance.Iframe.attachEvent( "onreadystatechange" , OnViewReady );
}

function OnViewReady()
{
if( Instance.Iframe.readyState != 'complete' )
{
return;
}

Instance.Iframe.style.border = 0;
Instance.Iframe.detachEvent( "onreadystatechange" , OnViewReady );

if (Instance.WithParentContext == true)
{
getIframeWindow().open = OnWindowOpen;
}

if (m_iframeShowModalDialogFunc == null)
{
m_iframeShowModalDialogFunc = getIframeWindow().showModalDialog;
getIframeWindow().showModalDialog = OnIframeShowModalDialog;
}

if (Instance.EntityCode > 0)
{
if (m_windowAutoFunc == null)
{
m_windowAutoFunc = window.auto;
window.auto = OnWindowAuto;
}
}

m_iframeDoc = getIframeDocument();
m_iframeDoc.body.scroll = "no";
m_iframeDoc.body.style.padding = "0px";
}

function OnWindowOpen( url , name , features )
{
if( url.indexOf('?') == -1 )
{
url = url.split('#')[0] + "?_CreateFromType=" + crmForm.ObjectTypeCode + "&_CreateFromId=" + crmForm.ObjectId;
}

return window.open( url , name , features );
}

function OnIframeShowModalDialog(sUrl, vArguments, sFeatures)
{
m_iframeShowModalDialogFunc(sUrl, vArguments, sFeatures);
Instance.Refresh();
}

function OnWindowAuto(otc)
{
if ( otc == Instance.EntityCode )
{
getIframeDocument().all.crmGrid.Refresh();
}

m_windowAutoFunc(otc);
}

function getIframeDocument()
{
return getIframeWindow().document;
}

function getIframeWindow()
{
return Instance.Iframe.contentWindow;
}
}

OnCrmPageLoad();



Источник: http://mscrm4ever.blogspot.com/2009/...me-part-2.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
mscrm4ever: CRM 4.0 Many 2 Many IFrame Viewer Blog bot Dynamics CRM: Blogs 0 12.04.2009 16:05
mscrm4ever: Displaying an Image in an IFRAME Blog bot Dynamics CRM: Blogs 0 10.02.2009 21:06
Microsoft Dynamics CRM Team Blog: List Web Part for Microsoft Dynamics CRM 4.0 Deployment Scenarios Blog bot Dynamics CRM: Blogs 0 30.01.2009 22:05
Microsoft Dynamics CRM Team Blog: List Web Part for Microsoft Dynamics CRM 4.0: Understanding Connections Blog bot Dynamics CRM: Blogs 0 20.01.2009 02:07
Microsoft Dynamics CRM Team Blog: Announcing List Web Part for Microsoft Dynamics CRM 4.0 Blog bot Dynamics CRM: Blogs 0 18.12.2008 06:06
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра
Комбинированный вид Комбинированный вид

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 04:39.