sort.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /****************************************************************
  2. ** Licensed Materials - Property of IBM
  3. **
  4. ** BI and PM: qs
  5. **
  6. ** (C) Copyright IBM Corp. 2001, 2015
  7. **
  8. ** US Government Users Restricted Rights - Use, duplication or
  9. ** disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  10. *****************************************************************/
  11. // Copyright (C) 2008 Cognos ULC, an IBM Company. All Rights Reserved.
  12. // Cognos and the Cognos logo are trademarks of Cognos ULC (formerly Cognos Incorporated) in the United States and/or other countries. IBM and the IBM logo are trademarks of International Business Machines Corporation in the United States, or other countries, or both. Other company, product, or service names may be trademarks or service marks of others.
  13. function execute()
  14. {
  15. var oSortFeature = goDialogManager.getThisFeatureObject();
  16. var sOrderValue;
  17. var sTestValue = "";
  18. var idxCtr = 0;
  19. if (oSortFeature.m_sOpType == 'numeric')
  20. {
  21. for (idxCtr = 0; idxCtr < document.f.numericOrder.length; idxCtr++)
  22. {
  23. if ( document.f.numericOrder[idxCtr].checked === true )
  24. {
  25. sOrderValue = document.f.numericOrder[idxCtr].value;
  26. }
  27. }
  28. sTestValue = document.f.numericOrder.value;
  29. }
  30. else if (oSortFeature.m_sOpType == 'alpha')
  31. {
  32. for (idxCtr = 0; idxCtr < document.f.alphaOrder.length; idxCtr++)
  33. {
  34. if ( document.f.alphaOrder[idxCtr].checked === true )
  35. {
  36. sOrderValue = document.f.alphaOrder[idxCtr].value;
  37. }
  38. }
  39. sTestValue = document.f.alphaOrder.value;
  40. }
  41. else
  42. {
  43. for (idxCtr = 0; idxCtr < document.f.otherOrder.length; idxCtr++)
  44. {
  45. if ( document.f.otherOrder[idxCtr].checked === true )
  46. {
  47. sOrderValue = document.f.otherOrder[idxCtr].value;
  48. }
  49. }
  50. sTestValue = document.f.otherOrder.value;
  51. }
  52. var bSummSort = false;
  53. if (document.f.details !== null && document.f.details[1].checked)
  54. {
  55. bSummSort = true;
  56. }
  57. if (sTestValue == 'N' || !bSummSort)
  58. {
  59. goDialogManager.getFeatureManager().executeFeature("Sort", new Array(sOrderValue, false, 0));
  60. }
  61. else
  62. {
  63. goDialogManager.getFeatureManager().executeFeature("Sort", new Array(sOrderValue, true, document.f.summary.value));
  64. }
  65. };
  66. function setupDialog()
  67. {
  68. var oSortFeature = goDialogManager.getThisFeatureObject();
  69. if (goDialogManager.getEnvParam("currentSortOrder") === '' && oSortFeature.m_sGroupName.length > 0)
  70. {
  71. document.f.details[0].disabled = true;
  72. document.f.details[0].checked = true;
  73. document.f.details[1].disabled = true;
  74. }
  75. if (oSortFeature.m_bIsCrosstab === true)
  76. {
  77. document.getElementById("detailsOnly").className = "clsTextDisable";
  78. if ((goDialogManager.getEnvParam("currentSortOrder").toUpperCase() == 'A') || (goDialogManager.getEnvParam("currentSortOrder").toUpperCase() == 'D'))
  79. {
  80. document.f.details[1].disabled = false;
  81. }
  82. else
  83. {
  84. document.f.details[1].disabled = true;
  85. }
  86. document.f.details[0].disabled = true;
  87. document.f.details[1].checked = true;
  88. }
  89. if (typeof(document.f.summary) == "object")
  90. {
  91. if (document.f.summary.selectedIndex === -1)
  92. {
  93. document.f.summary.selectedIndex = 0;
  94. }
  95. }
  96. var oColNameText = document.getElementById("colNameText");
  97. oColNameText.appendChild(document.createTextNode(decodeURIComponent(oSortFeature.m_aParams["xxColName"])));
  98. if (oSortFeature.m_sOpType == 'numeric')
  99. {
  100. document.getElementById("displayNumeric").style.display = "inline";
  101. document.getElementById("displayAlphanumeric").style.display = "none";
  102. document.getElementById("displayOther").style.display = "none";
  103. }
  104. else if (oSortFeature.m_sOpType == 'alpha')
  105. {
  106. document.getElementById("displayNumeric").style.display = "none";
  107. document.getElementById("displayAlphanumeric").style.display = "inline";
  108. document.getElementById("displayOther").style.display = "none";
  109. }
  110. else
  111. {
  112. document.getElementById("displayNumeric").style.display = "none";
  113. document.getElementById("displayAlphanumeric").style.display = "none";
  114. document.getElementById("displayOther").style.display = "inline";
  115. }
  116. if (oSortFeature.m_sGroupName.length > 0)
  117. {
  118. document.getElementById('displayBasedOn').style.display = "inline";
  119. if (goDialogManager.getEnvParam("includeAllOption")
  120. && goDialogManager.getEnvParam("currentSortByIndex") === -1)
  121. {
  122. document.f.summary.options[0].selected = "true";
  123. }
  124. else
  125. {
  126. for (var idxCtr = 0; idxCtr < oSortFeature.m_sGroupName.length; idxCtr++)
  127. {
  128. var aLabelAndIndex = oSortFeature.m_sGroupName[idxCtr];
  129. document.f.summary.options[document.f.summary.options.length] = new Option(aLabelAndIndex[0], aLabelAndIndex[1]);
  130. if (goDialogManager.getEnvParam("currentSortByIndex") == aLabelAndIndex[1])
  131. {
  132. document.f.summary.options[document.f.summary.options.length-1].selected = "true";
  133. }
  134. }
  135. }
  136. }
  137. };
  138. function setState(bEnabled)
  139. {
  140. var oSortFeature = goDialogManager.getThisFeatureObject();
  141. if (oSortFeature.m_bIsCrosstab === true)
  142. {
  143. document.f.summary.disabled = !bEnabled;
  144. document.f.details[1].disabled = !bEnabled;
  145. if (!bEnabled)
  146. {
  147. document.getElementById("summariesOf").className = "clsTextDisable";
  148. }
  149. else
  150. {
  151. document.getElementById("summariesOf").className = "";
  152. }
  153. }
  154. else if (oSortFeature.m_sGroupName.length > 0)
  155. {
  156. document.f.details[0].disabled = !bEnabled;
  157. document.f.details[1].disabled = !bEnabled;
  158. if (!bEnabled)
  159. {
  160. document.getElementById("detailsOnly").className = "clsTextDisable";
  161. document.getElementById("summariesOf").className = "clsTextDisable";
  162. document.f.summary.disabled = true;
  163. }
  164. else
  165. {
  166. document.getElementById("detailsOnly").className = "";
  167. document.getElementById("summariesOf").className = "";
  168. if (document.f.details[1].checked)
  169. {
  170. document.f.summary.disabled = false;
  171. }
  172. }
  173. }
  174. return true;
  175. };
  176. function changeSummaryState(bEnabled)
  177. {
  178. document.f.summary.disabled = !bEnabled;
  179. };