powercomparegrid.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * 返回json格式中 最好默认带有ID列
  3. 默认显示 20列
  4. * 列表id = 'gridTable'
  5. 列表url = 'Handler.ashx?action=page'
  6. 列表datatype = 'json'
  7. 列表colNames = ['ID', '名称', '性别', '手机', '邮箱']
  8. 列表colModel = 。。。
  9. 列表标题 caption = '用户列表'
  10. 列表修改URL editurl = 'Handler.ashx?action=oper'
  11. 列表默认排序 sortname = 'ID';
  12. 页码ID gridPagerID = 'gridPager'
  13. */
  14. //最后选中的行
  15. var lastsel;
  16. function myJqGrid(id, url, datatype, colNames, colModel, caption,
  17. sortname, gridPagerID,sortorder,height,width,
  18. multiselect,rownumbers) {
  19. var myGrid = $('#' + id);
  20. myGrid.jqGrid({
  21. url: url,
  22. datastr: 'data.json',
  23. datatype: datatype,
  24. height:height,
  25. width:width,
  26. rowNum: 10000,
  27. rowList: [10, 20, 50],
  28. colNames: colNames,
  29. colModel: colModel,
  30. loadtext:"读取数据中。。。",
  31. jsonReader: {
  32. repeatitems: false,
  33. root: function (obj) { return obj.rows; },
  34. page: function (obj) { return obj.pageindex; },
  35. total: function (obj) { return obj.pagecount; },
  36. records: function (obj) { return obj.total; }
  37. },
  38. prmNames: {
  39. page: 'page',
  40. rows: 'pageSize',
  41. sort: 'sortorder',
  42. order: 'sortname'
  43. },
  44. hidegrid: false,
  45. rownumbers: rownumbers,
  46. multiselect:multiselect,
  47. loadonce: false,
  48. sortname: sortname,
  49. sortorder: sortorder,
  50. pager: '#' + gridPagerID,
  51. viewrecords: true,
  52. caption: caption,
  53. //toolbar: [true, 'top'],
  54. altRows: true,
  55. //最后选中的行
  56. onSelectRow: function (id) {
  57. if (id && id !== lastsel) {
  58. myGrid.jqGrid('restoreRow', lastsel);
  59. lastsel = myGrid.jqGrid('getRowData', id)[sortname];
  60. }
  61. },
  62. onCellSelect: function(rowid, index, contents, event) {
  63. if(rowid!=null && rowid!='null')
  64. {
  65. goWtInfo(rowid);
  66. }
  67. }
  68. });
  69. }