Hi folks,
I'm trying to filter subgrid on (Account) form load. But I'm unable to get the subgrid control. Below is my code:
The name of the subgrid is "BrokerAccounts"
function filterBrokerView() {
//Filter connection subgrid
function FilterConnectionSubgrid() {
var ConnectionSubgrid = document.getElementById("BrokerAccounts");
if (ConnectionSubgrid == null) {
setTimeout(filterBrokerView, 2000); //if the grid hasn’t loaded run this again
return;
}
else if(ConnectionSubgrid != null)
{
alert("Subgrid found");
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"
+ "<entity name='new_broker'>"
+ "<attribute name='new_name' />"
+ "<attribute name='new_distributorid' />"
+ "<attribute name='createdon' />"
+ "<order attribute='new_name' descending='false' />"
+ "<filter type='and'>"
+ "<condition attribute='statecode' operator='eq' value='0' />"
+ "</filter>"
+ "</entity>"
+ " </fetch>";
ConnectionSubgrid.control.setParameter("fetchXml", fetchXml);
//Refresh grid to show filtered records only.
ConnectionSubgrid.control.Refresh();
}
}
}
This (alert("Subgrid found");) code do not execute even after the page loads.
Kindly guide me how to filter subgrid.
Thanks,
Muhammad