Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.00 KB | None | 0 0
  1. DataHandler.getAssignedTasks(Id, Role, Type, city, Flag, Loc, Month, cat, Act,
  2. { callback : function(data){
  3. /**
  4. * Setting result values into local variable
  5. */
  6. resultSet = data;
  7. var Grid = $("#Grid");
  8.  
  9. /**
  10. * Deciding the sorting format according to the Date format.
  11. */
  12. var sortingType = "";
  13. if("yy/mm/dd" == gUserDateFormat)
  14. {
  15. sortingType = 'text';
  16. }
  17. else if("dd/mm/yy" == gUserDateFormat)
  18. {
  19. sortingType = 'date';
  20. }
  21.  
  22. /**
  23. * Configure the grid for the required fields with values and load the data in
  24. * the DIV 'taskGrid'
  25. */
  26.  
  27. Grid.jqGrid({
  28. datatype : "local",
  29. data : resultSet,
  30. height : (gridRows * 7) + 5,
  31. width : pageInnerWidth - (pageInnerWidth * 0.1225),
  32. sortable : false,
  33. ignoreCase : true,
  34. sortorder : "desc",
  35. colNames : ['Title', 'Location','Act', 'mat', 'Date', 'Status', 'Action', 'Aging', 'Imp', 'Mon', 'Rev', 'Type', 'city'],
  36. colModel : [{
  37. name : 'title',
  38. index : 'title',
  39. formatter : function(cellValue, rowObject) {
  40. return '<a href="taskDetails?taskId=' + rowObject.rowId + '" target="_blank">' + cellValue + '</a>';
  41. },
  42. width : '160',
  43. align : 'left',
  44. sorttype : 'text'
  45. },{
  46. name : 'cLocation',
  47. index : 'cLocation',
  48. width : '275',
  49. align : 'left',
  50. sorttype : 'text',
  51. hidden : hideLocationData
  52. },{
  53. name : 'act',
  54. index : 'act',
  55. width : '160',
  56. align : 'left',
  57. sorttype : 'text'
  58. }, {
  59. name : 'mat',
  60. index : 'mat',
  61. width : '160',
  62. align : 'left',
  63. sorttype : 'text'
  64. },{
  65. name : 'date',
  66. index : 'date',
  67. width : '120',
  68. align : 'left',
  69. sorttype : sortingType,
  70. datefmt: 'd/m/Y',
  71. sortable: true,
  72. formatoptions: {srcformat: 'd/m/Y', newformat:'d/m/Y'}
  73. }, {
  74. name : 'status',
  75. index : 'status',
  76. width : '110',
  77. align : 'left',
  78. sorttype : 'text'
  79. }, {
  80. name : 'actionLink',
  81. index : 'actionLink',
  82. formatter : function(cellValue, rowObject) {
  83. return '<a href="companyDetails?taskId=' + rowObject.rowId + '" target="_blank">' + cellValue + '</a>';
  84. },
  85. width : '80',
  86. align : 'left',
  87. sortable : false,
  88. searchable : false,
  89. hidden : hideActionLink
  90. }, {
  91. name : 'aging',
  92. index : 'aging',
  93. width : '70',
  94. align : 'left',
  95. sorttype : 'numeric'
  96. }, {
  97. name : 'imp',
  98. index : 'imp',
  99. width : '120',
  100. align : 'left',
  101. sorttype : 'text',
  102. hidden : hideimpData
  103. }, {
  104. name : 'mon',
  105. index : 'mon',
  106. width : '120',
  107. align : 'left',
  108. sorttype : 'text',
  109. hidden : hideMonData
  110. }, {
  111. name : 'revName',
  112. index : 'revName',
  113. width : '120',
  114. align : 'center',
  115. sorttype : 'text',
  116. hidden : hideRevData
  117. }, {
  118. name : 'typeName',
  119. index : 'typeName',
  120. width : '5',
  121. align : 'center',
  122. sorttype : 'text',
  123. hidden : true,
  124. searchoptions : { searchhidden : true }
  125. }, {
  126. name : 'cityName',
  127. index : 'cityName',
  128. width : '5',
  129. align : 'center',
  130. sorttype : 'text',
  131. hidden : true,
  132. searchoptions : { searchhidden : true }
  133. }
  134. ],
  135. rowList : [ 15, 30, 50, 75, 100 ],
  136. pager : '#taskPager',
  137. rowNum : gridRows,
  138. altRows : true,
  139. altclass : "myclass",
  140. viewrecords : true
  141. });
  142.  
  143. if (!searchEnabledOnTaskGrid)
  144. {
  145. /**
  146. * Configure the grid 'taskGrid' to enable search on fields
  147. */
  148. taskGrid.jqGrid('filterToolbar',{
  149. searchOnEnter : false,
  150. defaultSearch : "cn",
  151. beforeSearch : function(){
  152. if (specialCharactersCheck($("#gs_title").val())
  153. || specialCharactersCheck($("#gs_cLocation").val())
  154. || specialCharactersCheck($("#gs_act").val())
  155. || specialCharactersCheck($("#gs_mat").val())
  156. || specialCharactersCheck($("#gs_date").val())
  157. || specialCharactersCheck($("#gs_statusText").val())
  158. || specialCharactersCheck($("#gs_actionLink").val())
  159. || specialCharactersCheck($("#gs_aging").val())
  160. || specialCharactersCheck($("#gs_impName").val())
  161. || specialCharactersCheck($("#gs_monName").val())
  162. || specialCharactersCheck($("#gs_revName").val())
  163. || specialCharactersCheck($("#gs_typeName").val())
  164. || specialCharactersCheck($("#gs_cityName").val()))
  165. {
  166. return true;
  167. }
  168. else
  169. {
  170. valtypeName = $("#typeName option:selected").text();
  171. if (valTaskType == "Show All")
  172. {
  173. valtypeName = "";
  174. }
  175.  
  176. valcity = $("#city option:selected").text();
  177. if (valcity == "Show All")
  178. {
  179. valcity = "";
  180. }
  181.  
  182. var myGrid = $("#taskGrid");
  183. var myFilter = {groupOp: "AND", mats: []};
  184. var postData = myGrid.jqGrid('getGridParam','postData');
  185. var searchData = jQuery.parseJSON(postData.filters);
  186. for (var iMat = 0; iMat < searchData.rules.length; iMat ++)
  187. {
  188. myFilter.mats.push({ field: searchData.mats[iMat ].field, op: "cn", data: searchData.mats[iMat ].data });
  189. }
  190. if (valtypeName .length !== 0)
  191. {
  192. myFilter.mats.push({ field: "typeName", op: "cn", data: valtypeName });
  193. }
  194. if (valcity.length !== 0)
  195. {
  196. myFilter.mats.push({ field: "cityName", op: "cn", data: valcity });
  197. }
  198. myGrid[0].p.search = true;
  199. $.extend(myGrid[0].p.postData, { filters: JSON.stringify(myFilter) });
  200. myGrid.trigger("reloadGrid", [{ page: 1, current: true}]);
  201. return true;
  202. }
  203. }
  204. });
  205.  
  206. searchEnabledOnTaskGrid = true;
  207. }
  208. },
  209. errorHandler : function(){
  210. },
  211. async : false
  212. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement