Always keep the Filter section expanded in AxGridView

During AxUG Webinar, I got a question around how to keep the filter section always expanded in a gridview in Microsoft Dynamics AX 2009 EP. Unfortunately we don't have a simple property to do that in the AxGridView control. Since it's all ASP.NET and javascript, I mentioned that there should be an easy workaround available.
If you add the below javascript code to your user control at the bottom of the markup file ( .ascx file) then the filter section will always be in expanded mode both during initial load as well as during subsequent postbacks. Since the below code uses lot's of internals such as ids and stylesheet names, it is not guaranteed to work in subsequent releases of EP. But if you need this capability in  Ax 2009 and specific pages, this may be useful.

 

<script type="text/javascript">

function ExpandFilter(sender, args) {

var elem = document.getElementById('div_<%=this.AxGridView1.FilterControl.ClientID%>');

var parentDiv = elem.parentNode;

var filterArea = DynamicsFilter.GetFilterArea(elem);

if (DynamicsCommon.IsNull(filterArea)) return;

elem.style.display = '';

var applylink = DynamicsCommon.FindInstance(parentDiv, "applyfilter");

var resetlink = DynamicsCommon.FindInstance(parentDiv, "resetfilter");

var editfilterlink = DynamicsCommon.FindInstance(parentDiv, "editfilter");

if (!DynamicsCommon.IsNull(applylink) && !DynamicsCommon.IsNull(resetlink) && !DynamicsCommon.IsNull(editfilterlink)) {

editfilterlink.style.display = 'none';

applylink.style.display = '';

resetlink.style.display = '';

}

}

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(ExpandFilter);

ExpandFilter();

</

script>