Dynamics CRM 2011过滤器子网格和刷新

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Dynamics CRM 2011过滤器子网格和刷新相关的知识,希望对你有一定的参考价值。

Filters a dynamics CRM 2011 subgrid...implementation example included at bottom
  1. if (typeof (EASI) == "undefined")
  2. { EASI = {}; }
  3. EASI._construct = function () {
  4. //filter subgrid and refresh function
  5. this.FilterSubgridandRefresh = function (subgridname, stringArrayOfCondtionsToAdd, removeExistingConditionsBool) {
  6. try {
  7. window.setTimeout(function () {
  8.  
  9. var subgrid = document.getElementById(subgridname);
  10.  
  11. if (subgrid == undefined || subgrid == null)
  12. {
  13. throw "EASI SubGridFetchBuilder...subgrid not ready...contact [email protected]";
  14. }
  15.  
  16. var oldFetch = $("#" + subgridname).find("#effectiveFetchXml").attr("value");
  17. if (oldFetch == undefined) {
  18. //we have to refresh the grid now because it was in a tab that was collapsed so it hasn't run yet
  19. subgrid.control.refresh();
  20. //re-run this operation
  21. setTimeout(function () {
  22. EASI.FilterSubgridandRefresh(subgridname, stringArrayOfCondtionsToAdd, removeExistingConditionsBool);
  23. }, 1000);
  24. }
  25. else {
  26. var html_fetch = $("<div>" + oldFetch + "</div>");
  27. if (removeExistingConditionsBool)//remove the existing conditions
  28. html_fetch.find("condition[operator!='']").remove();
  29. for (var i in stringArrayOfCondtionsToAdd) {
  30. var cond = $(stringArrayOfCondtionsToAdd[i]);
  31. html_fetch.find("filter").append(cond);
  32. }
  33. var newFetch = html_fetch.html();
  34. subgrid.control.SetParameter("fetchXml", newFetch);
  35. subgrid.control.refresh();
  36. }
  37. }, 1000);
  38. }
  39. catch (err) {
  40. alert("Error in subgrid refresh " + err.message);
  41.  
  42. }
  43. }
  44. //get crm field value function
  45. this.GetFieldValue = function (fieldlogicalname) {
  46. if (typeof (Xrm) == "undefined")
  47. Xrm = window.parent.Xrm;
  48. var atype = Xrm.Page.getControl(fieldlogicalname).getAttribute().getAttributeType();
  49.  
  50. if (atype == this.CRM.type_optionset) {
  51. return this.GetPicklistSelectedValue(fieldlogicalname);
  52. }
  53. else if (atype == this.CRM.type_lookup) {
  54. return this.GetLookupId(fieldlogicalname);
  55. }
  56. else {
  57. return Xrm.Page.getControl(fieldlogicalname).getAttribute().getValue();
  58. }
  59. }
  60.  
  61. }
  62.  
  63. EASI._construct();
  64.  
  65. /*here is an implementation example*/
  66. function filterGrid_Load() {
  67.  
  68. var oid = $("#opportunityid").attr("value");
  69. var configno = EASI.GetFieldValue("easi_configurationno");
  70. FilterSubGrid_OppDetailSubgrid("DoNotRemove_options_subgrid", oid, configno, 101);
  71. function FilterSubGrid_OppDetailSubgrid(subgridname, oppid, configno, lineitemtype) {
  72. try {
  73. var newcond1 = "<condition attribute="easi_configurationno" operator="eq" value="" + configno + "" />";
  74. var newcond2 = "<condition attribute="opportunityid" operator="eq" value="" + oppid + "" />";
  75. var newcond3 = "<condition attribute="easi_lineitemtype" operator="eq" value="" + lineitemtype + "" />";
  76. var newcond4 = "<condition attribute="easi_removeoption" operator="ne" value="" + 1 + "" />";
  77. var condArray = new Array(newcond1, newcond2, newcond3, newcond4);
  78. EASI.FilterSubgridandRefresh(subgridname, condArray, true);
  79. }
  80. catch (err) {
  81. alert("error filtering subgrid: " + err.message);
  82. }
  83. }
  84. }

以上是关于Dynamics CRM 2011过滤器子网格和刷新的主要内容,如果未能解决你的问题,请参考以下文章

Dynamics CRM 访问团队的使用

Dynamics CRM 2011 - 如何更改现有 CRM 实例的活动目录服务器?

EndpointNotFound 异常 - Dynamics CRM 2011

sql 在另一个用户的背景下阅读MS Dynamics CRM过滤视图

JavaScript 有用的Dynamics CRM 2011表格脚本花絮

Dynamics CRM 2011 批量更新