• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
MSCRM janmson
MS CRM顾问及二次开发
博客园    首页    新随笔    联系   管理    订阅  订阅

Default Multi-column Sort (Proof of Concept)

from   http://crmentropy.blogspot.com/2009/10/default-multi-column-sort.html

may be use this mechanism sometimes. so log it.

Being able to sort by multiple columns in CRM is quite handy, but unfortunately there are no mechanisms for configuring a default multi-column sort. Until now. The following code will illustrate how to accomplish it:
var stageFrame = document.getElementsByName("stage")[0]; 
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:
  1. First, get the document that holds the crmGrid;
  2. Then, access the divGridProps collection within it;
  3. 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)
  4. Repeat the bracketed block as necessary, being sure to place a semicolon (;) between each field/sort pair.
There must be NO SPACES. Finally, call a Refresh() on the grid. The downside to this code, is that it does not update the sorting icon on the columns. There's a call being made somewhere, and I think it has to do with analyzing the keypress+click event, that updates the image... whereas my code does not follow that code path.

UPDATE:  You may have noticed that the code above references a mechanism for changing the sorting of the currently viewed CRM Grid from the main CRM window, but makes no mention of where to put the code.  This is because I have not researched, or located, a way to load custom Javascript into the main CRM window.  This code is proof-of-concept.
posted @ 2009-12-03 11:25  韩建兴  阅读(290)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3