'I have 2 subGrids on a form, the second of which filters based on record select of the first subGrid, however, on deselect of the record, the related subGrid filter remains. How do I remove this filter if the record is deselected? Mt code below for the filter:'
function subgridOnSelect(executionContext)
{
var selected = executionContext.getFormContext().data.entity;
var Id = selected.getId();
formContext = window.ALLCONTEXT;
if(Id != undefined && Id != null)
{
addSubgridEventListener(Id,formContext);
}
else
{
formContext.data.refresh();
}
}
function addSubgridEventListener(recordid,formContext)
{
var gridContext = formContext.getControl("subgrid_teamstemplatechannelfolders");
//ensure that the subgrid is ready…if not wait and call this function again
if (gridContext == null)
{
setTimeout(function () { addSubgridEventListener(recordid,formContext); }, 500);
return;
}
//bind the event listener when the subgrid is ready
var fetchxml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
" <entity name='sis_teamstemplatechannelfolder'>" +
" <attribute name='sis_channelnameid' />" +
" <attribute name='sis_foldermembergroupid' />" +
" <attribute name='sis_foldername' />" +
" <attribute name='sis_parentfolderid' />" +
" <attribute name='sis_teamstemplatechannelfolderid' />" +
" <order attribute='sis_foldername' descending='false' />" +
" <filter type='and'>" +
" <condition attribute='sis_channelnameid' operator='eq' value='"+recordid+"' uiname='Teams Template Channel Test 1' uitype='sis_teamstemplatechannel' />" +
" </filter>" +
" </entity>" +
"</fetch>";
gridContext.setFilterXml(fetchxml);
gridContext.refresh();
}
ALLCONTEXT;
function Onload(executionContext)
{
ALLCONTEXT = executionContext.getFormContext();
}