var stageFrame = document.getElementsByName("stage"); var stageFrameDoc = stageFrame.contentWindow.document; crmGrid = stageFrameDoc.all.crmGrid; crmGrid.all.divGridProps.children["sortColumns"].value = "statuscode:0;casetypecode:1"; crmGrid.Refresh()I spent some time trying to answer this question: http://social.microsoft.com/Forums/en-US/crmdevelopment/thread/bd082f9d-1288-49ea-a8b4-e2b0beefd1d4. And came up with the solution above.
Basically, it's implemented as this:
- First, get the document that holds the crmGrid;
- Then, access the divGridProps collection within it;
- Change the value for the "sortColumns" property to "<field name 1>:<sort type>[; <field name x>:<sort type>]" where: <field name> is the name of the sorted column <sort type> is 1 (descending) or 0 (ascending)
- Repeat the bracketed block as necessary, being sure to place a semicolon (;) between each field/sort pair.