For grid in main form(public view/associated view in main form)
var stageFrame = document.getElementsByName("stage")[0]; var stageFrameDoc = stageFrame.contentWindow.document; crmGrid = stageFrameDoc.all.crmGrid; crmGrid.all.divGridProps.children["sortColumns"].value = "fieldname:0;fieldname:1"; crmGrid.Refresh();
For grid in left nav(public view/associated view)
GetIframe("new_incident_new_entityname"); function GetIframe(loadAreaId) { var isNativeEntity = false; var navElement = document.getElementById('nav_' + loadAreaId); if (navElement == null) { navElement = document.getElementById('nav' + loadAreaId); isNativeEntity = true; } if (navElement != null) { navElement.onclick = function LoadAreaOverride() { // Call the original CRM method to launch the navigation link and create area iFrame if (isNativeEntity) { loadArea('area' + loadAreaId); Iframe = document.getElementById('area' + loadAreaId + 'Frame'); //put code to get gridobject here (grid from main form) } else { loadArea(loadAreaId); Iframe = document.getElementById(loadAreaId + 'Frame'); //put code to get gridobject here (grid from left nav) function IframeReady() { if (Iframe.readyState != 'complete') { return; } var stageFrameDoc = Iframe.contentWindow.document; crmGrid = stageFrameDoc.all.crmGrid; crmGrid.all.divGridProps.children["sortColumns"].value = "fieldname>:0;fieldname>:0"; crmGrid.Refresh(); } Iframe.onreadystatechange = IframeReady; } } } }
Notes:
- Change the value for the "sortColumns" property to "
: [; : ]" where: is the name of the sorted column is 1 (descending) or 0 (ascending). - Repeat the bracketed block as necessary, being sure to place a semicolon (;) between each field/sort pair.
No comments:
Post a Comment