wtcurve.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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: 5000,
  27. loadtext:"读取数据中。。。",
  28. loadui:'block',
  29. rowList: [10, 20, 50],
  30. colNames: colNames,
  31. colModel: colModel,
  32. jsonReader: {
  33. repeatitems: false,
  34. root: function (obj) { return obj.rows; },
  35. page: function (obj) { return obj.pageindex; },
  36. total: function (obj) { return obj.pagecount; },
  37. records: function (obj) { return obj.total; }
  38. },
  39. prmNames: {
  40. page: 'page',
  41. rows: 'pageSize',
  42. sort: 'sortorder',
  43. order: 'sortname'
  44. },
  45. hidegrid: false,
  46. rownumbers: rownumbers,
  47. multiselect:multiselect,
  48. loadonce: true,
  49. sortname: sortname,
  50. sortorder: sortorder,
  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. }
  64. });
  65. }