Search code examples
javascriptdynamics-crm-2011crmsubgrid

CRM 2011 - Filtered Subgrids Search Functionality


I found a way how to make "Filtered Subgrids" work with JavaScript, but when I add the "Search Box" on the subgrid, it searches on all the records and not on the records that are the result of the filtering.

Basicly, the only thing we do is putting an "FetchXML" while we click on a row in "Subgrid A" and "Subgrid B" is getting the new "FetchXML". Unfortunately we can't search in "Subgrid B" anymore, it searches in "ALL" records, and it should only search in the new "FetchXML". Has someone made this work in CRM 2011?

The only thing I do, is the following :

//Setting the fetch xml to the sub grid.
relatedSamples.control.setParameter("fetchXml", fetchXml);
relatedSamples.control.setParameter("effectiveFetchXml", fetchXml);
relatedSamples.control.setParameter("fetchXmlForFilters", fetchXml);

//This statement will refresh the sub grid after making all modifications.
relatedSamples.control.refresh();

Solution

  • Take a look at your effectiveFetchXml after the search. You'll notice that it doesn't include the effectiveFetchXml you initially passed to it.

    Unfortunately, the only way around this is the hijack the search button to fire your own event. In your event pass the effectiveFetchXml you want including the value of the search box (e.g. inject something like this when searching "t"...

    <filter type="or">
    <condition attribute="subject" operator="like" value="t%" />
    <condition attribute="regardingobjectidname" operator="like" value="t%" />
    </filter>