Показать сообщение отдельно
Старый 24.09.2013, 18:35   #6  
Ion is offline
Ion
Участник
 
332 / 16 (1) ++
Регистрация: 19.12.2012
Я код переписал, мне не ясно почему если пишу так, то переменная содержит значение reguestGrid {...} Object, (FormUIControl)


Цитата:
var reguestGrid =Xrm.Page.ui.controls.get('new_dogovorGrid')._control;


А переменная reguestGrid = undefined, когда пишу таким образом document.getElementById("new_dogovorGrid") = [Object, HTMLDivElement]

Цитата:
var reguestGrid = document.getElementById("new_dogovorGrid")


Цитата:

function filterSubGrid() {


var Casko = 100000001;
var Osago = 100000000;

var reguestGrid =Xrm.Page.ui.controls.get('new_dogovorGrid')._control;

var reguestGrid1 = document.getElementById("new_dogovorGrid");

debugger;

if (reguestGrid != null)
{
if (reguestGrid .readyState != "complete")
{
setTimeout(filterSubGrid, 1000);
return;
}
}
else
{
setTimeout(filterSubGrid, 1000);
return;
}

var accountValue = Xrm.Page.getAttribute("new_account").getValue(); //field to filter by
var ProductValue = Xrm.Page.getAttribute("new_insurance_product").getValue(); //field to filter by

var accountId = "00000000-0000-0000-0000-000000000000"; //if filter field is null display nothing

if (accountValue != null && (ProductValue == Casko || ProductValue == Osago)) {
var accountId = accountValue[0].id;
}

//fetch xml code which will retrieve all the accounts related to the contact
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
" <entity name='new_request'>" +
" <attribute name='new_requestid' />" +
" <attribute name='new_insurance_product' />" +
" <attribute name='new_insuransepayment' />" +
" <attribute name='new_total_limit' />" +
" <attribute name='new_client_account' />" +
" <order attribute='new_insurance_product' descending='false' />" +
" <filter type='and'>" +
" <condition attribute='new_client_account' operator='eq' uitype='account' value='" + accountId + "' />" +
" <condition attribute='new_insurance_product' operator='eq' value='" + ProductValue + "'/>" +
" <condition attribute='new_stage' operator='eq' value='100000006' />" +
" <condition attribute='new_result' operator='eq' value='1' /> " +
" </filter>" +
" </entity>" +
"</fetch>";

if (typeof reguestGrid.control.setParameter != "undefined"){
reguestGrid.control.setParameter("fetchXml", fetchXml);
}

if (typeof reguestGrid.control.SetParameter != "undefined"){
reguestGrid.control.SetParameter("fetchXml", fetchXml);

}

}